[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] storing a float value to a 8-bit registers
From: |
Abhijeet D Mhatre |
Subject: |
Re: [avr-gcc-list] storing a float value to a 8-bit registers |
Date: |
Wed, 28 May 2003 09:27:17 +0530 |
User-agent: |
KMail/1.4.1 |
> Delatils of float/double representation should not be interesting for C
> users. In fact we are using C language to "forget" such details. But it is
> very important to know percision of the given float/double representation
>clipping and
> scaling like that:
> double decibels;
> int16_t idecibels;
> if ( decibles < 0.0 )
> idecibels = (decibels-0.005)*100.0;
> else
> idecibels = (decibels+0.005)*100.0;
Thanks Artur
I didnt imagine the solution to be so easy. I was thinking I would have to
dig into the way the nos are stored.
One more thing.
Wouldn't it be safer to cast the float to an int.
idecibels =(int) (decibels-0.005)*100.0;
--
Regards
Abhijeet D Mhatre
Email: address@hidden