Thread overview
[Issue 308] New: Documentation of float.max_exp, min_exp is misleading
Aug 24, 2006
d-bugmail
Sep 09, 2006
d-bugmail
Sep 13, 2006
Don Clugston
Sep 13, 2006
d-bugmail
Sep 13, 2006
Don Clugston
Sep 14, 2006
d-bugmail
Sep 19, 2006
d-bugmail
August 24, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=308

           Summary: Documentation of float.max_exp, min_exp is misleading
           Product: D
           Version: 0.165
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: trivial
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: clugdbug@yahoo.com.au


The documentation describes min_exp as the "minimum exponent as power of 2",
but this is not correct, and it implies that real.min == pow(2, min_exp), but
actually real.min == pow(2, min_exp-1).
Likewise,
pow(2, max_exp-1) < real.max < pow(2, max_exp)

Perhaps change the definitions to be:
"minimum exponent as a power of 2, plus 1".
"maximum exponent as a power of 2, plus 1".

since they are really non-intuitive (see listing below).
Any idea why they've always been defined in C in such a bizarre way?

---
writefln(real.min_exp, " %a", real.min, " ", real.max_exp, " %a", real.max, "
");
writefln(double.min_exp, " %a", double.min, " ", double.max_exp, " %a",
double.max);
writefln(float.min_exp, " %a", float.min, " ", float.max_exp, " %a",
float.max);


-- 

September 09, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=308


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com




------- Comment #1 from smjg@iname.com  2006-09-09 18:50 -------
How do you know it's the spec that's wrong and not the complier?  Moreover, why are they min_exp and max_exp, not minExp and maxExp as per naming conventions?


-- 

September 13, 2006
d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=308
> 
> 
> smjg@iname.com changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |smjg@iname.com
> 
> 
> 
> 
> ------- Comment #1 from smjg@iname.com  2006-09-09 18:50 -------
> How do you know it's the spec that's wrong and not the complier?  Moreover, why
> are they min_exp and max_exp, not minExp and maxExp as per naming conventions?

Because they are the same values that C compilers return. Eg Visual C++ returns the same values. I don't know why C ended up with such a ridiculous definition, but those are the values used on all C/C++ compilers that I know of.

September 13, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=308





------- Comment #3 from smjg@iname.com  2006-09-13 05:29 -------
I could've sworn C didn't have any kind of properties on built-in types.


-- 

September 13, 2006
d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=308
> 
> 
> 
> 
> 
> ------- Comment #3 from smjg@iname.com  2006-09-13 05:29 -------
> I could've sworn C didn't have any kind of properties on built-in types.

They're in <float.h>. They don't have the same syntactic sugar as D, of course.

#define	FLT_MAX_EXP	128
#define FLT_MIN_10_EXP	-37
#define	FLT_MIN_EXP	-125
#define	DBL_MAX_EXP	1024
#define	DBL_MIN_EXP	-1021

etc.
September 14, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=308





------- Comment #5 from smjg@iname.com  2006-09-14 17:52 -------
They have different notations, so AFAIC there's no reason to assume that they're supposed to be the same.


-- 

September 19, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=308


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #6 from bugzilla@digitalmars.com  2006-09-19 15:27 -------
Fixed in DMC 0.167.


--