POV-Ray : Newsgroups : povray.general : QUESTION: Programming: Converting Floats to 255-Integers : Re: QUESTION: Programming: Converting Floats to 255-Integers Server Time
25 Apr 2024 20:17:21 EDT (-0400)
  Re: QUESTION: Programming: Converting Floats to 255-Integers  
From: dick balaska
Date: 27 Apr 2018 15:41:21
Message: <5ae37ce1$1@news.povray.org>
On 04/27/2018 02:56 PM, Sven Littkowski wrote:

 > I might have to round these numbers then, I guess. But that means losing
 > exactness.
 >

Well, yeah. That is the nature of the beast.  floating point (a double) 
gives you 52 bits of precision and integer color "256" is 8 bits.

I wouldn't worry about it. The human eye can't really tell the 
difference between RGB(121,85,198) and RGB(122,85,198).


> Example:
> 
> color rgb < 0.4748656, 0.3364377, 0.7790974 >

R = 0.4748656 * 255   = 121
G = 0.3364377 * 255   =  85
B = 0.7790974 * 255   = 198


(I never understood why the x87 uses 80 bit numbers internally, to 
minimize rounding error in calculations, but only allowed inputs and 
outputs of 64 bits. Why can't I have all those bits?)

-- 
dik
Rendered 328976 of 330000 (99%)


Post a reply to this message

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