Xref: utzoo comp.sources.wanted:6946 comp.unix.wizards:15372 comp.sys.sgi:897 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!killer!texbell!bellcore!faline!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.sources.wanted,comp.unix.wizards,comp.sys.sgi Subject: Re: Float to sign/exp/mantissa Message-ID: <9151@alice.UUCP> Date: 4 Apr 89 17:09:13 GMT References: <1026@cs-spool.calgary.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 27 In article <1026@cs-spool.calgary.UUCP>, paquette@cpsc.ucalgary.ca (Trevor Paquette) writes: > I am sure that someone out there has a routine that given > a floating point number, what is the sign, exponent and mantissa > of the number.. The widely available frexp() library function gives you most of what you want. After executing the following: double x; double frexp(); double mant; int exp; x = /* some value */; mant = frexp(x, &exp); you are guaranteed that x is equal to mant * 2^^exp (here, ^^ means exponentiation), that 0.5 <= |mant| < 1, and that the sign of mant is the same as the sign of x, except that if x is 0, mant and exp will be 0 too. That should make it easy for you to get what you want. -- --Andrew Koenig ark@europa.att.com