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

Formatting of floating point #120

Open
binkley opened this issue Feb 19, 2022 · 1 comment
Open

Formatting of floating point #120

binkley opened this issue Feb 19, 2022 · 1 comment

Comments

@binkley
Copy link
Owner

binkley commented Feb 19, 2022

There are challenges when using BigDecimal and constructors such as BigDecimal(Double) vs BigDecimal(String). For example: BigDecimal(1.0) has different "scale" than BigDecimal("1.0")

Design & implement a consistent policy for FloatingBigRational. Options may include:

  1. Follow the patterns of BigDecimal
  2. Always show a decimal point to emphasize the floating-point nature, eg, "3.0 / 2.0" vs "3 / 2"

Present code leans towards the former (partly by accident).

@binkley
Copy link
Owner Author

binkley commented Mar 18, 2022

Note that internally FloatingBigRational is still the ratio of two BigIntegers, not two BigDecimals. Option 2 would imply:

println(FixedBigRational.valueOf(2))
println(FloatingBigRational.valueOf(2))

prints:

3/2
3.0/2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant