avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] Re: [bug #23677] Request for cbrt() and strdup to be adde


From: hutchinsonandy
Subject: [avr-libc-dev] Re: [bug #23677] Request for cbrt() and strdup to be added to lic
Date: Mon, 23 Jun 2008 13:02:39 -0400


Trust me x == 0.0 is abolutely safe. This is a specfic number. The test looks for a specfic number. Log 0.0 is an error otherwise. log (0.0000000000000000000000.................000000000000000001) is not an error.


FYI You can also exactly test for other small integers in FP with no ambiguity. The limit depends on precision but 32767.0 is safe enough for 32 bit IEEE float (and most all? others) - without needing to get the books out.

The problem comes with decimal fractions like 0.1 - which is not exactly represented.
So x == 0.1 will always fail.

Binary fractions like 0.125, 0.25 0.5 are also ok.

Another problem comes up when you output numbers in decimal ASCII (printf). This rounds values to nearest decimal number.
Yet another is input (like scanf) - where decimal is rounded to binary.

But 0.0 is safe.

The example pointer check can use 0 or NULL - I dont care as long as it works.

Personally I'd write the code - and see what asm looks like, then diddle with it to get best code.

:-)


----------------------------------------------
Sent from my Dingleberry wired device.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]