[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [avr-libc-dev] Math.h additions

**From**: |
Colin O'Flynn |

**Subject**: |
[avr-libc-dev] Math.h additions |

**Date**: |
Sat, 9 Aug 2003 07:06:03 -0700 (PDT) |

Hello,
There are a few additions to math.h that I think would
bring it closer to ANSI specs and are very easy to
do... maybe I've missed them somewhere else or
something, but they are:
1) define NaN type (is 0xFFC0xxxx according to various
FP libs and the readme)
#define NAN 0xFFC00000
2) define positive infinity
#define INFINITY 0x7FFFFFFF
2.5) Maybe define HUGE_VAL and HUGE_VALF
#define HUGE_VAL INFINITY
#define HUGE_VALF INFINITY
3) Define function int signbit(double x); which
returns nonzero value if and only if the sign-bit is
negative.
This would be pretty easy, something along the lines
of (written in perso-code)
return (int)(R25 AND 0x80);
R25 holds the exponent + sign of the double, so you
just strip everything else.. if its positive (sign bit
= 0) it returns 0, but if the sign bit is 1
(negative), then it returns 0x80 (128 dec).
There are a few more functions as well of course, but
these seemed to be almost implimented anyway and
really just a case of adding the documentation and a
few lines of code...
-Colin

**[avr-libc-dev] Math.h additions**,
*Colin O'Flynn* **<=**