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

Switch all Small Basic numerics to a decimal64-based 'Number' type #137

Open
McSherry opened this issue Jul 27, 2020 · 0 comments
Open

Switch all Small Basic numerics to a decimal64-based 'Number' type #137

McSherry opened this issue Jul 27, 2020 · 0 comments
Labels
pri/3 Priority 3 - Something that can be done in SBO 1.1 or later type/runtime Issues related to runtime engine

Comments

@McSherry
Copy link
Member

McSherry commented Jul 27, 2020

This issue stems from a Yammer discussion.

Small Basic should switch to using the IEEE decimal64 format to represent its numbers. This would:

  • Retain the intuitive ability of .NET decimal to represent decimal fractions (as opposed to float and double's binary fractions)
  • Avoid any potentially unintuitive (to beginners) side effects of the various type conversions Small Basic does
  • Provide opportunities to increase maths performance over .NET's non-standard decimal type, which has been a source of complaints in the past
  • Expand the range at the cost of precision, from 10±28 with 34-digit precision (.NET decimal) to between 10−383 and 10+384 with 16-digit precision. Most learners would probably value added range over being able to represent the weight of an electron in grams (which, FWIW, is 9.11×10−28).
  • Improve Small Basic's portability to constrained platforms—a platform such as a BBC micro:bit might use decimal32 instead, which retains all the same semantics with more limited range and precision. If the decimal64 implementation were limited to the range of decimal32, the switch would only incur a reduction in precision, easing understanding.
@McSherry McSherry added the type/runtime Issues related to runtime engine label Jul 27, 2020
@Caseysch Caseysch added the pri/3 Priority 3 - Something that can be done in SBO 1.1 or later label Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pri/3 Priority 3 - Something that can be done in SBO 1.1 or later type/runtime Issues related to runtime engine
Projects
None yet
Development

No branches or pull requests

2 participants