1 ! (c)2009 Joe Groff bsd license
2 USING: accessors alien.accessors alien.c-types alien.data
3 alien.syntax kernel math math.order ;
7 : half>bits ( float -- bits )
9 [ -31 shift 15 shift ] [
12 dup 0x7f800000 >= [ -13 shift 0x7fff bitand ] [
20 : bits>half ( bits -- float )
21 [ -15 shift 31 shift ] [
24 dup 0x7c00 >= [ 13 shift 0x7f800000 bitor ] [
29 ] bi bitor bits>float ;
38 [ alien-unsigned-2 bits>half ] >>getter
39 [ [ >float half>bits ] 2dip set-alien-unsigned-2 ] >>setter
43 [ >float ] >>unboxer-quot