<html><head><style type="text/css"><!-- DIV {margin:0px} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">>I agree, but wouln't it be better to mult. by 65536 instead of 65536 as follow:<br>>if (f <= 0) x = 0; else if (f < 1) x = (int)(f*65536); else x = 65535;<br>>because otherwise even values very near from 1.0 (like 1.0- 1.e-9) would be 65534.<br>or better :<br>
if (f <= 0) x = 0; else if (f < 1-epsilon) x = (int)(f*65536); else x = 65535;<br>
to avoid round approx to 65536 when f is very close to 1, epsilon could still be 1.e-5 <br><br>
Fabien<br><br></div></div></body></html>