|
![](/i/fill.gif) |
In article <405dd981$1@news.povray.org>,
"Thorsten Froehlich" <tho### [at] trf de> wrote:
> > Hmm...yes it is. To write "1.5" in a portable way in text only requires
> > writing those three characters. In binary you need to write it byte by
> > byte in a known floating point format and byte ordering, regardless of
> > what the native machine format is.
>
> This is simply not correct. You can perfectly represent a floating-point
> number with two integers. In fact, a floating-point number is exactly that!
> Consequently, representing it as text gains you nothing except the false
> impression that you can get an exact value representation.
Floating point numbers are a bit more than a simple ratio, they are
usually a binary version of scientific notation. The most common form
uses a sign bit, a normalized mantissa, and a biased exponent. The
allocation of individual bits and the actual layout can vary. While the
text representation may not exactly match the internal value, it will be
written and read the same way on any platform, which is not guaranteed
for floating point values in binary files. For that, you must explicitly
define the layout and write your own code for reading and writing binary
float values. This isn't very difficult, but it is another step to take.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tag povray org>
http://tag.povray.org/
Post a reply to this message
|
![](/i/fill.gif) |