Hi Kevin, > I'm getting strange results with the following: > ... > : (scl 16) > -> 16 > : (setq Ptr (%@ "malloc" 'P 4)) > -> 9674752 > : (struct Ptr NIL (list -1.0 1280.0)) > -> NIL > : (format (car (struct Ptr '(-1.0 . 1))) *Scl) > -> "-103.5058256155770880" > ... > The value seems completely off; the examples for 'struct work fine.
It is a floating point range problem. The IEEE 'float' type cannot support such high precision (16 digits). If you do (setq Ptr (%@ "malloc" 'P 4)) (scl 7) (format (struct Ptr -1.0 (-1.0 123.0)) *Scl) -> "123.0000000" it works fine, but for higher scales it more and more disintegrates, as in your example above. Using IEEE 'double' helps for a while (setq Ptr (%@ "malloc" 'P 8)) (scl 15) (format (struct Ptr 1.0 (1.0 123.0)) *Scl) -> "123.000000000000000" but no longer for 16 (scl 16) (format (struct Ptr 1.0 (1.0 123.0)) *Scl) -> "7.7078495393153024" ☺/ A!ex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe