summaryrefslogtreecommitdiff
path: root/src/math/big/float_test.go
Commit message (Collapse)AuthorAgeFilesLines
* math/big: round x + (-x) to -0 for mode ToNegativeInfBrian Kessler2018-06-141-0/+25
| | | | | | | | | | | | | | | | | | | | | | Handling of sign bit as defined by IEEE 754-2008, section 6.3: When the sum of two operands with opposite signs (or the difference of two operands with like signs) is exactly zero, the sign of that sum (or difference) shall be +0 in all rounding-direction attributes except roundTowardNegative; under that attribute, the sign of an exact zero sum (or difference) shall be −0. However, x+x = x−(−x) retains the same sign as x even when x is zero. This change handles the special case of Add/Sub resulting in exactly zero when the rounding mode is ToNegativeInf setting the sign bit accordingly. Fixes #25798 Change-Id: I4d0715fa3c3e4a3d8a4d7861dc1d6423c8b1c68c Reviewed-on: https://go-review.googlesource.com/117495 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
* all: update comment URLs from HTTP to HTTPS, where possibleTim Cooper2018-06-011-2/+2
| | | | | | | | | | Each URL was manually verified to ensure it did not serve up incorrect content. Change-Id: I4dc846227af95a73ee9a3074d0c379ff0fa955df Reviewed-on: https://go-review.googlesource.com/115798 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
* math/big: fix %s verbs in Float tests error messagesAlberto Donizetti2018-02-141-5/+5
| | | | | | | | | | | | | | | | | | | Fatalf calls in two Float tests use the %s verb with Floats values, which is not allowed and results in failure messages that look like this: float_test.go:1385: i = 0, prec = 1, ToZero: %!s(*big.Float=1) [0] / %!s(*big.Float=1) [0] = %!s(*big.Float=0.0625) want %!s(*big.Float=1) Switch to %v. Change-Id: Ifdc80bf19c91ca1b190f6551a6d0a51b42ed5919 Reviewed-on: https://go-review.googlesource.com/87199 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* math/big: fix Add, Sub when receiver aliases 2nd operandAlberto Donizetti2017-05-311-0/+28
| | | | | | | | | | Fixes #20490 Change-Id: I9cfa604f9ff94df779cb9b4cbbd706258fc473ac Reviewed-on: https://go-review.googlesource.com/44150 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* math/big: move exhaustive tests behind -long flagRuss Cox2016-10-111-3/+6
| | | | | | | | | This way you can still run 'go test' or 'go bench -run Foo' without wondering why it is taking so very long. Change-Id: Icfa097a6deb1d6682acb7be9f34729215c29eabb Reviewed-on: https://go-review.googlesource.com/30707 Reviewed-by: Robert Griesemer <gri@golang.org>
* math/big: avoid allocation in float.{Add, Sub} when there's no aliasingAlberto Donizetti2016-08-171-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | name old time/op new time/op delta FloatAdd/10-4 116ns ± 1% 82ns ± 0% -28.74% (p=0.008 n=5+5) FloatAdd/100-4 124ns ± 0% 86ns ± 1% -30.34% (p=0.016 n=4+5) FloatAdd/1000-4 192ns ± 1% 123ns ± 0% -35.94% (p=0.008 n=5+5) FloatAdd/10000-4 826ns ± 0% 438ns ± 0% -46.99% (p=0.000 n=4+5) FloatAdd/100000-4 6.82µs ± 1% 3.36µs ± 0% -50.74% (p=0.008 n=5+5) FloatSub/10-4 108ns ± 1% 77ns ± 1% -29.06% (p=0.008 n=5+5) FloatSub/100-4 115ns ± 0% 79ns ± 0% -31.48% (p=0.029 n=4+4) FloatSub/1000-4 168ns ± 0% 99ns ± 0% -41.09% (p=0.029 n=4+4) FloatSub/10000-4 690ns ± 2% 288ns ± 1% -58.24% (p=0.008 n=5+5) FloatSub/100000-4 5.37µs ± 1% 2.10µs ± 1% -60.89% (p=0.008 n=5+5) name old alloc/op new alloc/op delta FloatAdd/10-4 48.0B ± 0% 0.0B ±NaN% -100.00% (p=0.008 n=5+5) FloatAdd/100-4 64.0B ± 0% 0.0B ±NaN% -100.00% (p=0.008 n=5+5) FloatAdd/1000-4 176B ± 0% 0B ±NaN% -100.00% (p=0.008 n=5+5) FloatAdd/10000-4 1.41kB ± 0% 0.00kB ±NaN% -100.00% (p=0.008 n=5+5) FloatAdd/100000-4 13.6kB ± 0% 0.0kB ±NaN% -100.00% (p=0.008 n=5+5) FloatSub/10-4 48.0B ± 0% 0.0B ±NaN% -100.00% (p=0.008 n=5+5) FloatSub/100-4 64.0B ± 0% 0.0B ±NaN% -100.00% (p=0.008 n=5+5) FloatSub/1000-4 176B ± 0% 0B ±NaN% -100.00% (p=0.008 n=5+5) FloatSub/10000-4 1.41kB ± 0% 0.00kB ±NaN% -100.00% (p=0.008 n=5+5) FloatSub/100000-4 13.6kB ± 0% 0.0kB ±NaN% -100.00% (p=0.008 n=5+5) Fixes #14868 Change-Id: Ia2b8b1a8ef0868288ecb25f812b17bd03ff40d1c Reviewed-on: https://go-review.googlesource.com/23568 Reviewed-by: Robert Griesemer <gri@golang.org>
* math/big: fix rounding to smallest denormal for Float.Float32/64Robert Griesemer2016-03-211-19/+42
| | | | | | | | | | | | | | | | | Converting a big.Float value x to a float32/64 value did not correctly round x up to the smallest denormal float32/64 if x was smaller than the smallest denormal float32/64, but larger than 0.5 of a smallest denormal float32/64. Handle this case explicitly and simplify some code in the turn. For #14651. Change-Id: I025e24bf8f0e671581a7de0abf7c1cd7e6403a6c Reviewed-on: https://go-review.googlesource.com/20816 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: use correct precision in Float.Float32/64 for denormalsRobert Griesemer2016-03-041-0/+47
| | | | | | | | | | | | | When a big.Float is converted to a denormal float32/64, the rounding precision depends on the size of the denormal. Rounding may round up and thus change the size (exponent) of the denormal. Recompute the correct precision again for correct placement of the mantissa. Fixes #14553. Change-Id: Iedab5810a2d2a405cc5da28c6de7be34cb035b86 Reviewed-on: https://go-review.googlesource.com/20198 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: remove (*Float).Scan, ScanFloat; more robust (*Float).ParseRobert Griesemer2015-05-291-17/+4
| | | | | | | | | | | | | | | | | | | - (*Float).Scan conflicted with fmt.Scanner.Scan; it was also only used internally. Removed it, as well as the companion ScanFloat function. - (*Float).Parse (and thus ParseFloat) can now also parse infinities. As a result, more code could be simplified. - Fixed a bug in rounding (round may implicitly be called for infinite values). Found via existing test cases, after simplifying some code. - Added more test cases. Fixes issue #10938. Change-Id: I1df97821654f034965ba8b82b272e52e6dc427f1 Reviewed-on: https://go-review.googlesource.com/10498 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: rename (*Float).Format to (*Float).TextRobert Griesemer2015-05-291-25/+25
| | | | | | | | | | | This paves the way for a fmt-compatible (*Float).Format method. A better name then Text is still desirable (suggestions welcome). This is partly fixing issue #10938. Change-Id: I59c20a8cee11f5dba059fe0f38b414fe75f2ab13 Reviewed-on: https://go-review.googlesource.com/10493 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: Always print exponent sign when using 'p' exponent for Floats.Robert Griesemer2015-05-221-15/+15
| | | | | | | | | | | | | | | Float.Format supports the 'b' and 'p' format, both of which print a binary ('p') exponent. The 'b' format always printed a sign ('+' or '-') for the exponent; the 'p' format only printed a negative sign for the exponent. This change makes the two consistent. It also makes the 'p' format easier to read if the exponent is >= 0. Also: - Comments added elsewhere. Change-Id: Ifd2e01bdafb3043345972ca22a90248d055bd29b Reviewed-on: https://go-review.googlesource.com/10359 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: fix Float.Float64 conversion for denormal corner casesRobert Griesemer2015-05-221-3/+2
| | | | | | | | | | | - This change uses the same code as for Float32 and fixes the case of a number that gets rounded up to the smallest denormal. - Enabled correspoding test case. Change-Id: I8aac874a566cd727863a82717854f603fbdc26c6 Reviewed-on: https://go-review.googlesource.com/10352 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: add more Float.Float64 conversion testsRobert Griesemer2015-05-221-35/+53
| | | | | | | | | | | | - structure the Float64 conversion tests the same way as for Float32 - add additional test cases, including one that exposes a current issue (currently disabled, same issue as was fixed for Float32) The Float64 fix will be in a subsequent change for easier reviewing. Change-Id: I95dc9e8d1f6b6073a98c7bc2289e6d3248fc3420 Reviewed-on: https://go-review.googlesource.com/10351 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: fix Float.Float32 conversion for denormal corner casesRobert Griesemer2015-05-221-35/+58
| | | | | | | | | | | | | | | | | | | The existing code was incorrect for numbers that after rounding would become the smallest denormal float32 (instead the result was 0). This caused all.bash to fail if Float32() were used in the compiler for constant arithmetic (there's currently a work-around - see also issue 10321. This change fixes the implementation of Float.Float32 and adds corresponding test cases. Float32 and Float64 diverge at this point. For ease of review, this change only fixes Float32. Float64 will be made to match in a subsequent change. Fixes #10321. Change-Id: Iccafe37c1593a4946bc552e4ad2045f69be62d80 Reviewed-on: https://go-review.googlesource.com/10350 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big, cmd/internal/gc/big: fix vet detected printf problemShenghou Ma2015-05-141-1/+1
| | | | | | | Change-Id: I54425d8cbe0277d7a0c9d66c37f2128a0dfa6441 Reviewed-on: https://go-review.googlesource.com/10041 Run-TryBot: Minux Ma <minux@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
* math/big: make ErrNaN actually implement the error interface (oversight)Robert Griesemer2015-04-081-0/+3
| | | | | | | | There was no way to get to the error message before. Change-Id: I4aa9d3d9f468c33f9996295bafcbed097de0389f Reviewed-on: https://go-review.googlesource.com/8660 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: implement missing special cases for binary operationsRobert Griesemer2015-04-021-17/+32
| | | | | | Change-Id: I9fc12b1a9b1554523e08839c1ff46c8668217ba1 Reviewed-on: https://go-review.googlesource.com/8381 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: remove NaN support - just not worth itRobert Griesemer2015-03-311-114/+81
| | | | | | | | | | | | | | | | | NaNs make the API more complicated for no real good reasons. There are few operations that produce NaNs with IEEE arithmetic, there's no need to copy the behavior. It's easy to test for these scenarios and avoid them (on the other hand, it's not easy to test for overflow or underflow, so we want to keep +/-Inf). Also: - renamed IsNeg -> Signbit (clearer, especially for x == -0) - removed IsZero (Sign() == 0 is sufficient and efficient) - removed IsFinite (now same as !IsInf) Change-Id: I3f3b4445c325d9bbb1bf46ce2e298a6aeb498e07 Reviewed-on: https://go-review.googlesource.com/8280 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: fixed Float.Float64, implemented Float.Float32Robert Griesemer2015-03-311-11/+96
| | | | | | | | | | - fix bounds checks for exponent range of denormalized numbers - use correct rounding precision for denormalized numbers - added extra tests Change-Id: I6be56399afd0d9a603300a2e44b5539e08d6f592 Reviewed-on: https://go-review.googlesource.com/8096 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: fix known bug in Float.Float64Robert Griesemer2015-03-241-6/+60
| | | | | | | | | | - handle exponent over- and underflow - handle denormalized numbers - added test cases Change-Id: I1bbb9904b0c104f54696944e1f57559881f6eeeb Reviewed-on: https://go-review.googlesource.com/7982 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: cleaner handling of exponent under/overflowRobert Griesemer2015-03-171-0/+62
| | | | | | | | Fixed several corner-case bugs and added corresponding tests. Change-Id: I23096b9caeeff0956f65ab59fa91e168d0e47bb8 Reviewed-on: https://go-review.googlesource.com/7001 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: wrap Float.Cmp result in struct to prevent wrong useRobert Griesemer2015-03-141-10/+10
| | | | | | | | | | | | | | | | | Float.Cmp used to return a value < 0, 0, or > 0 depending on how arguments x, y compared against each other. With the possibility of NaNs, the result was changed into an Accuracy (to include Undef). Consequently, Float.Cmp results could still be compared for (in-) equality with 0, but comparing if < 0 or > 0 would provide the wrong answer w/o any obvious notice by the compiler. This change wraps Float.Cmp results into a struct and accessors are used to access the desired result. This prevents incorrect use. Change-Id: I34e6a6c1859251ec99b5cf953e82542025ace56f Reviewed-on: https://go-review.googlesource.com/7526 Reviewed-by: Rob Pike <r@golang.org>
* math/big: fix minor documentation issueRobert Griesemer2015-03-131-1/+1
| | | | | | Change-Id: Ib42f75c03573cec16801b79a6eb9b1b542028f4f Reviewed-on: https://go-review.googlesource.com/7524 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: fix silly bug in Int64 accessorRobert Griesemer2015-03-131-0/+2
| | | | | | Change-Id: If335d45ea1ab6c8aeeb47515f97680e2c1d651f3 Reviewed-on: https://go-review.googlesource.com/7522 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: handle NaNs in Float.CmpRobert Griesemer2015-03-121-13/+45
| | | | | | | | | | | | | Also: - Implemented NewFloat convenience factory function (analogous to NewInt and NewRat). - Implemented convenience accessors for Accuracy values returned from Float.Cmp. - Added test and example. Change-Id: I985bb4f86e6def222d4b2505417250d29a39c60e Reviewed-on: https://go-review.googlesource.com/6970 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: added (internal) Float.form field for easier case distinctionsRobert Griesemer2015-03-121-18/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a fairly significant _internal_ representation change. Instead of encoding 0, finite, infinite, and NaN values with special mantissa and exponent values, a new (1 byte) 'form' field is used (without making the Float struct bigger). The form field permits simpler and faster case distinctions. As a side benefit, for zero and non-finite floats, fewer fields need to be set. Also, the exponent range is not the full int32 range (in the old format, infExp and nanExp were used to represent Inf and NaN values and tests for those values sometimes didn't test for the empty mantissa, so the range was reduced by 2 values). The correspondence between the old and new fields is as follows. Old representation: x neg mant exp --------------------------------------------------------------- +/-0 sign empty 0 0 < |x| < +Inf sign mantissa exponent +/-Inf sign empty infExp NaN false empty nanExp New representation (- stands for ignored fields): x neg mant exp form --------------------------------------------------------------- +/-0 sign - - zero 0 < |x| < +Inf sign mantissa exponent finite +/-Inf sign - - inf NaN - - - nan Client should not be affected by this change. Change-Id: I7e355894d602ceb23f9ec01da755fe6e0386b101 Reviewed-on: https://go-review.googlesource.com/6870 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: introduce Bits abstraction instead of using "untyped" []int bit listsRobert Griesemer2015-03-121-16/+16
| | | | | | Change-Id: I6caa6bdcf6643ce3015244397a752bd133f3d00c Reviewed-on: https://go-review.googlesource.com/6840 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: move "bits" operations used for Float tests into separate fileRobert Griesemer2015-03-061-197/+0
| | | | | | | | This is a pure code move without any semantic change. Change-Id: I2c18efc858955d07949b1241e793232f2cf1deb9 Reviewed-on: https://go-review.googlesource.com/6821 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: added more comprehensive mul/quo testRobert Griesemer2015-03-051-18/+85
| | | | | | Change-Id: Ib813eb5960c3310b1c919f25f687560f4f9d63b0 Reviewed-on: https://go-review.googlesource.com/6820 Reviewed-by: Russ Cox <rsc@golang.org>
* math/big: reenable TestFloatAdd32 (used to fail on 32bit platforms)Robert Griesemer2015-03-041-5/+0
| | | | | | Change-Id: I932c2f1b1d27c437722cd27d2001b085a655c572 Reviewed-on: https://go-review.googlesource.com/6722 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: use stringer for enum String() methodsRobert Griesemer2015-03-041-13/+33
| | | | | | Change-Id: Ide0615542d67b7d81bf6c56aab550e142a8789f7 Reviewed-on: https://go-review.googlesource.com/6682 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: introduce Undef Accuracy, use for NaN operands/resultsRobert Griesemer2015-03-041-22/+27
| | | | | | | | | | This change represents Accuracy as a bit pattern rather than an ordered value; with a new value Undef which is both Below and Above. Change-Id: Ibb96294c1417fb3cf2c3cf2374c993b0a4e106b3 Reviewed-on: https://go-review.googlesource.com/6650 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: modified MantExp semantics to enable fast exponent accessRobert Griesemer2015-03-041-11/+12
| | | | | | Change-Id: I9a6ebb747d5b9756c214bdeb19f60820602d7a24 Reviewed-on: https://go-review.googlesource.com/6340 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: implement NaNRobert Griesemer2015-03-041-9/+103
| | | | | | | | | | | | This change introduces NaNs (for situations like Inf-Inf, etc.). The implementation is incomplete (the four basic operations produce a NaN if any of the operands is an Inf or a NaN); and some operations produce incorrect accuracy for NaN arguments. These are known bugs which are documented. Change-Id: Ia88841209e47930681cef19f113e178f92ceeb33 Reviewed-on: https://go-review.googlesource.com/6540 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: replace Float.NewInf with Float.SetInf for more consistent APIRobert Griesemer2015-03-021-3/+24
| | | | | | Change-Id: I2a60ea4a196eef1af5d2aae6cc239c64bddb6fb2 Reviewed-on: https://go-review.googlesource.com/6301 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: export Float.MinPrecRobert Griesemer2015-02-261-0/+25
| | | | | | | | | MinPrec returns the minimum precision required to represent a Float without loss of precision. Added test. Change-Id: I466c8e492dcdd59fae854fc4e71ef9b1add7d817 Reviewed-on: https://go-review.googlesource.com/6010 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: fix build for 32bit platformsRobert Griesemer2015-02-261-4/+0
| | | | | | Change-Id: I9c217e5140294a17e4feb65da5b121ee8d8cadc2 Reviewed-on: https://go-review.googlesource.com/6050 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* math/big: clean up Float.SetPrec, use shorter internal representationRobert Griesemer2015-02-251-0/+52
| | | | | | Change-Id: I9b78085adc12cbd240d0b8b48db6810ddb2aeadd Reviewed-on: https://go-review.googlesource.com/5991 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: permit passing of an *Int to Float.Int to avoid allocationRobert Griesemer2015-02-251-2/+11
| | | | | | Change-Id: I50e83248357928e56c94b88a8764de828f4f5c76 Reviewed-on: https://go-review.googlesource.com/5890 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: implemented Float.RatRobert Griesemer2015-02-251-12/+57
| | | | | | Change-Id: If516e12d4b5dfb6f9288437d270569f7e4e2a1cd Reviewed-on: https://go-review.googlesource.com/5871 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: permit passing of (possibly nil) *Float to MantExp to avoid allocationRobert Griesemer2015-02-251-2/+13
| | | | | | Change-Id: Ia92eea833283f8b16fa09d4ca1c9cb3bc0eb18a2 Reviewed-on: https://go-review.googlesource.com/5870 Reviewed-by: Rob Pike <r@golang.org>
* math/big: fix test for 32bit platforms (fix build)Robert Griesemer2015-02-241-2/+0
| | | | | | | Change-Id: I73509cd0e0866cfe2b2ae46a26fb4d043dd050c4 Reviewed-on: https://go-review.googlesource.com/5840 Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* math/big: change Float.SetMantExp to always multiply mant by 2**expRobert Griesemer2015-02-241-2/+12
| | | | | | Change-Id: If840e647376a2141f8c17729f7ef251bfff13f5f Reviewed-on: https://go-review.googlesource.com/5810 Reviewed-by: Rob Pike <r@golang.org>
* math/big: incorporated feedback from prior TBR reviewsRobert Griesemer2015-02-231-0/+2
| | | | | | Change-Id: Ida847365223ef09b4a3846e240b4bb6919cb0fe9 Reviewed-on: https://go-review.googlesource.com/5610 Reviewed-by: Alan Donovan <adonovan@google.com>
* math/big: always round after the sign is setRobert Griesemer2015-02-151-0/+52
| | | | | | | | | | Some rounding modes are affected by the sign of the value to be rounded. Make sure the sign is set before round is called. Added tests (that failed before the fix). Change-Id: Idd09b8fcbab89894fede0b9bc922cda5ddc87930 Reviewed-on: https://go-review.googlesource.com/4876 Reviewed-by: Rob Pike <r@golang.org>
* math/big: remove Float.Round (not needed anymore), fix a bug in SetInt64Robert Griesemer2015-02-141-5/+32
| | | | | | | | TBR adonovan Change-Id: I30020f39be9183b37275e10a4fd1e1a3b4c48c89 Reviewed-on: https://go-review.googlesource.com/4880 Reviewed-by: Robert Griesemer <gri@golang.org>
* math/big: implement/rename accessors for precision and rounding modeRobert Griesemer2015-02-141-35/+36
| | | | | | | | | | | | | | | | | Also: remove NewFloat - not needed anymore. Work-around for places where has been used so far: NewFloat(x, prec, mode) === new(Float).SetMode(mode).SetPrec(prec).SetFloat64(x) However, if mode == ToNearestEven, SetMode is not needed. SetPrec is needed if the default precision (53 after SetFloat64) is not adequate. TBR adonovan Change-Id: Ifda12c479ba157f2dea306c32b47c7afbf31e759 Reviewed-on: https://go-review.googlesource.com/4842 Reviewed-by: Robert Griesemer <gri@golang.org>
* math/big: fix aliasing error in Add, SubRobert Griesemer2015-02-141-8/+14
| | | | | | | | | | | | | Also: - make representation more flexible (no need to store trailing 0 digits to match precision) - simplify rounding as a consequence - minor related fixes TBR adonovan Change-Id: Ie91075990688b506d28371ec3b633b8267397ebb Reviewed-on: https://go-review.googlesource.com/4841 Reviewed-by: Rob Pike <r@golang.org>
* math/big: use internal validation more consistentlyRobert Griesemer2015-02-141-0/+12
| | | | | | | | TBR adonovan Change-Id: If77afa6474af6cad6512f6866725e3ae5acf2e3f Reviewed-on: https://go-review.googlesource.com/4840 Reviewed-by: Robert Griesemer <gri@golang.org>
* math/big: implemented Float.Int64, simplified Float.Uint64Robert Griesemer2015-02-121-8/+58
| | | | | | Change-Id: Ic270ffa7ec6f6dd4b0a951c64ad965447cce1417 Reviewed-on: https://go-review.googlesource.com/4571 Reviewed-by: Alan Donovan <adonovan@google.com>