"Marco" == Marco Antoniotti <marcoxa@cs.nyu.edu> writes:
Marco> Now. I am trying to produce a version for LW that, at a minimum, implemented the following Marco> (defun make-single-float (x) Marco> (float x 1.0f0)) ; Would this “just work”? Nope. x is an integer, basically equal to the bits in a float. You want to take those bits and interpret them as a float. Something akin to the C code union { int n; float f; } var; var.n = x; /* Some integer */ printf("%g\n", var.f): /* Magically a floating point number */ Analogous union for doubles. Marco> (defun single-float-bits (x) Marco> (declare (type single-float x)) Marco> ;; Wrong for LW. No KERNEL:SINGLE-FLOAT-BITS. Marco> (ldb (byte 32 0) (kernel:single-float-bits x))) Using the union above, it's something like var.f = x; printf("%d\n", var.n); Marco> What do the two missing function actually do? Sorry. I Marco> tried to read the sources, but (1) I am too lazy and (2) I Marco> am way too rusty in deep lisping (cfr., functions that just Marco> call themselves :) ) Marco> Do they just get the actual bitwise representation of the Marco> floats assuming a Lisp representation? Pretty much. These functions basically give you a way to produce exactly a float value from the bit representation of the float and to extract the bit representation of a float. In cmucl for architectures that don't let you transfer a value between float register and an integer register, cmucl basically write out the float to memory and reads it back in, into an integer register, and vice versa. You will have to figure out how to get LW or your favorite impl to do something similar. -- Ray