1 ! Copyright (C) 2009 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.accessors alien.c-types alien.data
4 alien.syntax kernel math math.order ;
8 : half>bits ( float -- bits )
10 [ -31 shift 15 shift ] [
13 dup 0x7f800000 >= [ -13 shift 0x7fff bitand ] [
21 : bits>half ( bits -- float )
22 [ -15 shift 31 shift ] [
25 dup 0x7c00 >= [ 13 shift 0x7f800000 bitor ] [
30 ] bi bitor bits>float ;
39 [ alien-unsigned-2 bits>half ] >>getter
40 [ [ >float half>bits ] 2dip set-alien-unsigned-2 ] >>setter
44 [ >float ] >>unboxer-quot