Skip to content
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

wdte: use big.Float instead of float64 for Number #124

Open
DeedleFake opened this issue Sep 20, 2018 · 2 comments
Open

wdte: use big.Float instead of float64 for Number #124

DeedleFake opened this issue Sep 20, 2018 · 2 comments

Comments

@DeedleFake
Copy link
Owner

A bit of testing has found that big.NewFloat(n).Text('f', -1) seems to, not surprisingly, produce significantly cleaner textual representations of numbers than just plain fmt.Printf("%v") does, allowing, for example, much higher Fibonacci numbers to be printed without resulting in scientific notation. While I'm still debating whether or not it makes sense for wdte.Number to actually be a wrapper for big.Float directly, I think it makes sense to at least give it a String() method that uses the above for now.

@DeedleFake DeedleFake self-assigned this Sep 20, 2018
@DeedleFake DeedleFake added this to Todo in Initial Implementation via automation Sep 20, 2018
@DeedleFake
Copy link
Owner Author

After a bit more experimenting, it might not make sense to use just Text('f', -1). I'd like it to round large numbers of decimals but display large integers cleanly. I'm thinking something like the following:

if n.IsInt() {
  return n.Text('f', -1)
}

return n.Text('g', 10)

@DeedleFake DeedleFake changed the title Use big.Float to Produce Higher-Precision String Representations of Numbers Investigate Usage of big.Float in Place of float64 Sep 20, 2018
@DeedleFake
Copy link
Owner Author

While I'd like numbers to just be float64s to make usage of them a bit easier from the Go side, I'd also kind of like to somehow make Number capable of transparent precision-less math.

@DeedleFake DeedleFake changed the title Investigate Usage of big.Float in Place of float64 wdte: use big.Float instead of float64 for Number Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant