REBOL Technologies

Representing Decimals (floats) in REBin?

Carl Sassenrath, CTO
REBOL Technologies

Article #0043
Main page || Index || Prior Article [0042] || Next Article [0044] || Post Comments || Send feedback

The question has come up as to how to best represent decimal values with the REBOL Binary encoded format, REBin.

This is tricky because we want machine indpendence, but we also want optimal size. In other words, if we use the IEEE floating point format (that we use for REBOL internally), then each decimal value would require 8 bytes, even if the value is simply 1.0. Of course, it would load really fast (no conversion), but is IEEE FP compatible in binary form between all processors and libraries?

An alternative would be to use text format, but we might want to do some minor rounding to prevent the problem where 2.0 becomes 1.999999999999. Another method would be BCD (binary coded decimal) encoding of the text format.

If you have suggestions on this problem, please contact me via REBOL feedback or on AltME. Thanks.

Post Comments

Updated 7-Mar-2024   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code