Skip to content

Commit

Permalink
added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
twodayslate committed Dec 24, 2017
1 parent b248b01 commit ea501fb
Show file tree
Hide file tree
Showing 5 changed files with 434 additions and 12 deletions.
26 changes: 26 additions & 0 deletions Sources/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Marcel Kröker. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
47 changes: 38 additions & 9 deletions Sources/SMP.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,7 @@ public class BIntMath
else
{
last = Limb(arc4random_uniform(UInt32.max)) |
(Limb(arc4random_uniform(UInt32(2 ** (singleBits - 32)))) << 32)
(Limb(arc4random_uniform(UInt32(2.0 ** (singleBits - 32)))) << 32)
}

res.append(last)
Expand Down Expand Up @@ -2259,15 +2259,21 @@ public struct BDouble:

if sign
{
let den = ["1"] + [Character](repeating: "0", count: Int(afterExp)!)
self.init(beforeExp, over: String(den))
return
if let safeAfterExp = Int(afterExp) {
let den = ["1"] + [Character](repeating: "0", count: safeAfterExp)
self.init(beforeExp, over: String(den))
return
}
return nil
}
else
{
let num = beforeExp + String([Character](repeating: "0", count: Int(afterExp)!))
self.init(num, over: "1")
return
if let safeAfterExp = Int(afterExp) {
let num = beforeExp + String([Character](repeating: "0", count: safeAfterExp))
self.init(num, over: "1")
return
}
return nil
}
}

Expand Down Expand Up @@ -2354,10 +2360,29 @@ public struct BDouble:
}
set
{
_precision = abs(newValue)
var nv = newValue
if nv < 0 {
nv = 0
}
_precision = nv
}
}
private var _precision : Int = BDouble.precision
public var precision : Int
{
get
{
return _precision
}
set
{
var nv = newValue
if nv < 0 {
nv = 0
}
_precision = nv
}
}
public var precision : Int = BDouble.precision

public var decimalDescription : String
{
Expand Down Expand Up @@ -2754,3 +2779,7 @@ public func ceil(_ base: BDouble) -> BInt

return retVal
}

public func pow(_ base : BDouble, _ exp : Int) -> BDouble {
return base**exp
}
Loading

0 comments on commit ea501fb

Please sign in to comment.