math/big: first cut at multi-precision Floats
- implemented all rounding modes
- implemented +, -, *, /, and some unary ops
- implemented basic conversions
- written basic documentation
With precision set to 24 or 53, the results match
float32 or float64 operations exactly.
Known bugs: / doesn't round correctly in some cases.
CL IN PROGRESS.
Sending this out for interested parties. No need for thorough review yet - there's lots ...
10 years, 10 months ago
(2014-11-22 01:28:24 UTC)
#2
Sending this out for interested parties. No need for thorough review yet -
there's lots of stuff missing. But it is starting to come together.
API feedback welcome.
On Fri Nov 21 2014 at 5:26:04 PM <gri@golang.org> wrote:
> Reviewers: adonovan,
>
> Message:
> Hello adonovan@google.com (cc: golang-codereviews@googlegroups.com),
>
> I'd like you to review this change to
> https://code.google.com/p/go/
>
>
> Description:
> math/big: first cut at multi-precision Floats
>
> Working:
> - rounding to nearest
> - addition, subtraction (mostly), multiplication
> - basic conversions
>
> With precision set to 24 or 53, the results match
> float32 or float64 operations exactly.
>
> CL IN PROGRESS.
>
> Please review this at https://codereview.appspot.com/178140043/
>
> Affected files (+1189, -5 lines):
> A src/math/big/float.go
> A src/math/big/float_test.go
> M src/math/big/nat.go
> M src/math/big/nat_test.go
>
>
>
On 2014/11/22 22:09:32, adonovan wrote: > It would be interesting to record and replay the ...
10 years, 10 months ago
(2014-11-22 22:10:13 UTC)
#4
On 2014/11/22 22:09:32, adonovan wrote:
> It would be interesting to record and replay the API calls done by gc
compiling
> GOPATH+GOTOOL and see how the exact.Value implementation compares in time and
Er, where GOTOOL=golang.org/x/tools/...
thanks https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go File src/math/big/float.go (right): https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go#newcode38 src/math/big/float.go:38: // word x.mant[0]. The zero Float value is ...
10 years, 10 months ago
(2014-12-03 23:42:07 UTC)
#8
https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go File src/math/big/float.go (right): https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go#newcode430 src/math/big/float.go:430: return -v On 2014/12/03 23:42:05, gri wrote: > On ...
10 years, 10 months ago
(2014-12-03 23:49:11 UTC)
#9
https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go
File src/math/big/float.go (right):
https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go#ne...
src/math/big/float.go:430: return -v
On 2014/12/03 23:42:05, gri wrote:
> On 2014/12/03 22:15:03, adonovan wrote:
> > This looks wrong.
> > v will be zero if x is negative.
>
> ?
>
> it's tested for positive and negative numbers
Ah. That's because Uint64() returns the absolute value, which seems like a bug.
-1 should not silently become 1.
https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go#ne...
src/math/big/float.go:754: // x cmp (-y) == x
On 2014/12/03 23:42:06, gri wrote:
> On 2014/12/03 22:15:02, adonovan wrote:
> > This comment is very cryptic.
>
> same style as in Add, Sub, Mul
The other ones make notational sense, but these ones don't.
In particular, the middle two cases are not real equations.
I think you mean something like:
|x| cmp (-|y|) = 1
https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go File src/math/big/float.go (right): https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go#newcode430 src/math/big/float.go:430: return -v On 2014/12/03 23:49:11, adonovan wrote: > On ...
10 years, 10 months ago
(2014-12-04 00:06:36 UTC)
#10
https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go
File src/math/big/float.go (right):
https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go#ne...
src/math/big/float.go:430: return -v
On 2014/12/03 23:49:11, adonovan wrote:
> On 2014/12/03 23:42:05, gri wrote:
> > On 2014/12/03 22:15:03, adonovan wrote:
> > > This looks wrong.
> > > v will be zero if x is negative.
> >
> > ?
> >
> > it's tested for positive and negative numbers
>
> Ah. That's because Uint64() returns the absolute value, which seems like a
bug.
> -1 should not silently become 1.
Added TODO. The current implementation borrows from the Int.Int64 implementation
and semantics.
https://codereview.appspot.com/178140043/diff/190005/src/math/big/float.go#ne...
src/math/big/float.go:754: // x cmp (-y) == x
On 2014/12/03 23:49:11, adonovan wrote:
> On 2014/12/03 23:42:06, gri wrote:
> > On 2014/12/03 22:15:02, adonovan wrote:
> > > This comment is very cryptic.
> >
> > same style as in Add, Sub, Mul
>
> The other ones make notational sense, but these ones don't.
> In particular, the middle two cases are not real equations.
> I think you mean something like:
> |x| cmp (-|y|) = 1
Done.
R=close To the author of this CL: The Go project has moved to Gerrit Code ...
10 years, 9 months ago
(2014-12-19 05:16:29 UTC)
#11
R=close
To the author of this CL:
The Go project has moved to Gerrit Code Review.
If this CL should be continued, please see the latest version of
https://golang.org/doc/contribute.html for instructions on
how to set up Git and the Go project's Gerrit codereview plugin,
and then create a new change with your current code.
If there has been discussion on this CL, please give a link to it
(golang.org/cl/178140043 is best) in the description in your
new CL.
Thanks very much.
Issue 178140043: code review 178140043: math/big: first cut at multi-precision Floats
Created 10 years, 10 months ago by gri
Modified 7 hours, 5 minutes ago
Reviewers: fundasecgin32
Base URL:
Comments: 96