-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
math/big: SetMantExp doc comment unclear #47879
Comments
What it's saying is that for any x, you can deconstruct it with MantExp and reconstruct it with SetMantExp. The call to MantExp will happen first, setting Mant to the mantissa of x and returning the exponent. The arguments to SetMantExp are therefore the mantissa and exponent of x, so the call recreates x, stores it in the new Float, and Cmp returns 0. I didn't know this until I read the documentation. It's concise but accurate. It probably needs a phrase such as "given x". |
Ah right, because Actually, is this example useful? It isn't particularly difficult to see how one might pass in the results of |
Change https://golang.org/cl/344249 mentions this issue: |
https://cs.opensource.google/go/go/+/master:src/math/big/float.go;l=309
Hopefully I'm not having a moment of stupidity, but the example for
SetMantExp
doesn't make sense to me:What is
x
here? I assume that it is an arbitrary*Float
, although it would be good if that were stated explicitly.This is saying that
is equal to
x
(.Cmp(x) == 0
).new(Float).SetMantExp(mant, x.MantExp(mant))
looks like it should be a zero*Float
sincemant
is a zero*Float
. The exponent is set to the same asx
(andmant
is set to the mantissa ofx
although not used later) but that does not matter since the mantissa is zero. Based off my algebra skills from a long time ago,x
should be a zero*Float
then, to satisfy this example.What exactly is this example supposed to demonstrate? If it is just demonstrating using a mantissa outside of
[0.5, 1)
, I can think of many clearer examples.The text was updated successfully, but these errors were encountered: