POV-Ray : Newsgroups : povray.programming : POV-Ray on non-IEEE floating-point compatible platforms : POV-Ray on non-IEEE floating-point compatible platforms Server Time
28 Jul 2024 08:28:38 EDT (-0400)
  POV-Ray on non-IEEE floating-point compatible platforms  
From: Thorsten Froehlich
Date: 21 Sep 2002 08:57:10
Message: <3d8c6ca6$1@news.povray.org>
While there are not many such platforms left, those who still need them and
have ISO C99 compatible libraries may want to try to adjust the ot_index_box
function in octree.cpp to use the logbf / ilogbf C99 library function, which
is available in most recent compilers for Unix platforms.  below is the
example code that demonstrates how to adapt the code.  The actual POV-Ray
code change is left as an exercise to the reader ;-)

    Thorsten


NOTE: Be aware that is is most likely far less efficient, but it is
compatible with ISO C99 libraries!  I only provide the version using logbf
because the library I used for testing listed ilogbf as not yet supported...


#include <stdio.h>
#include <math.h>

int main(void)
{
 union
 {
  float f;
  long l;
 }
 convert;

 convert.f = -8614.585434574;
 convert.l &= 0xff800000;

 printf("%f %f\n", pow(2.0, logbf(convert.f) *(1-2*signbit(convert.f)),
                   convert.f);

 convert.f = -84.585434574;
 convert.l &= 0x7f800000;

 printf("%f %x %d %d %d\n", convert.f, convert.l, (convert.l>>23)-127,
                            (convert.l>>23), ((int)logbf(convert.f))+127);

 return 0;
}


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.