Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

math.frexp - what's it mean?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


skip at pobox

Sep 12, 2001, 2:06 PM

Post #1 of 3 (282 views)
Permalink
math.frexp - what's it mean?

>>> mantissa, exponent = math.frexp(5e40)

Not being a numeric type person, "frexp" conjured up absolutely no mnemonic
significance for me. The library reference manual was no help either.
Finally, I tried "man frexp" and got "convert floating-point number to
fractional and integral components". Now I know what it means mnemonically
("FRaction EXPonent", I guess), but the name is still perplexing. Why not
"manexp"? Does its use predate its appearance in C?

Skip


phr-n2001 at nightsong

Sep 12, 2001, 3:22 PM

Post #2 of 3 (252 views)
Permalink
math.frexp - what's it mean? [In reply to]

The term "mantissa" in math traditionally means the fractional part of
log_10(x). Programmers sometimes use the term to mean frac(x) but that's
inconsistent with the math usage. So I think "frexp" is more accurate
and clear than "manexp".


tim.one at home

Sep 12, 2001, 4:22 PM

Post #3 of 3 (253 views)
Permalink
math.frexp - what's it mean? [In reply to]

[Skip Montanaro]
> Not being a numeric type person, "frexp" conjured up absolutely
> no mnemonic significance for me. The library reference manual was no
> help either. Finally, I tried "man frexp" and got "convert floating-
> point number to fractional and integral components".

That's a particularly lame man page -- I'd only say that of modf(), which
actually does break a float into fractional and integral components (like
math.modf(7.25) == (0.25, 7.0)).

> Now I know what it means mnemonically ("FRaction EXPonent", I guess),
> but the name is still perplexing.

Good for you, Skip! I never had any idea what it meant, and never thought
to wonder. When I was learning C and Unix, it was just another senseless
string to memorize ('cat' to copy a file to stdout, 'ls' to display a
directory, 'frexp' to break up a float, 'ldexp' to multiply by a power of 2,
... all the same to me at the time).

> Why not "manexp"?

Why 'modf'? OS people can't even name OS functions sensibly; they're
hopeless when it comes to libm functions <wink>.

> Does its use predate its appearance in C?

AFAIK the name 'frexp' originated there.

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.