Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/28/00 05:42
Read: times


 
#3445 - RE: Floating point math pack...
Hi David,

(189/255)*17.5=12.970588.
But its not wise to suggest such high accuracy
only on an 8 bit input value.
(188/255)*17.5=12.90
So a resolution of 2 digits after the decimalpoint seems enough.

Why you not use integer ?
E.g. 189 / 255 * 17.5 * 100 = 1297
So:
Y = X * 17.5 * 100 / 255
Y = X * 6.86
Y = X * 449757 / 65536

On using 32 bit integer, you must only multilpy with 449757.
The division by 65536 was easy made with shifting right by 16 bits
(use simple the upper 2 bytes as a 16 bit result.
Since the result was multiplied by 100, the lower 2 digits
must be displayed after the decimal point:
189 * 449757 / 65536 = 1297 (display: 12.97)


Peter


List of 9 messages in thread
TopicAuthorDate
Floating point math pack...            01/01/70 00:00      
RE: Floating point math pack...            01/01/70 00:00      
RE: Floating point math pack...            01/01/70 00:00      
RE: Floating point math pack...            01/01/70 00:00      
RE: Floating point math pack...            01/01/70 00:00      
RE: Floating point math pack...            01/01/70 00:00      
RE: Floating point math pack...            01/01/70 00:00      
RE: Floating point math pack...            01/01/70 00:00      
RE: Floating point math pack...            01/01/70 00:00      

Back to Subject List