Hi!
----
Someone reported a problem with typeset -l -X (e.g. print value as the
same format as the C99 "hexfloat" (=printf "%a") format) which causes
the the hexfloat string representation not fully matching the internal
binary IEEE754-2008 value, resulting in problems when a "serialised"
hexfloat value is read-back into a float value and then compared to the
original.
Example:
The following shows what happens if a plain "float" value is converted
to an ASCII string and then matched against it's original:
-- snip --
$ ksh93 -c 'float y y_ascii; (( y=sin(90) )) ; y_ascii=$y ; (( y ==
y_ascii )) || print "no match,\n\t$(printf "%a\n" y)\n!=\n\t$(printf
"%a\n" y_ascii)"'
no match,
0x1.c9b9ee41cb8665c7890a136ace6bp-01
!=
0x1.c9b9ee41ca4c55484fddb568b23ap-01
-- snip --
Originally "typeset -X" (=floating-point variable with hexfloat) was
created to avoid this problem by using the hexfloat representation,
however there is still a difference in ast-ksh.2009-05-05:
-- snip --
$ ksh93 -c 'typeset -l -X y y_ascii; (( y=sin(90) )) ; y_ascii=$y ; (( y
== y_ascii )) || print "no match,\n\t$(printf "%a\n" y)\n!=\n\t$(printf
"%a\n" y_ascii)"'
no match,
0x1.c9b9ee41cb8665c7890a136ace6bp-01
!=
0x1.c9b9ee41cc000000000000000000p-01
-- snip --
Workaround:
Replace:
-- snip --
y_ascii=$y
-- snip --
with
-- snip --
y_ascii=$(printf "%a\n" y)
-- snip --
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) [email protected]
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users