www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 308] New: Documentation of float.max_exp, min_exp is misleading

reply d-bugmail puremagic.com writes:
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);


-- 
Aug 24 2006
next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=308


smjg iname.com changed:

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





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?


-- 
Sep 09 2006
parent Don Clugston <dac nospam.com.au> writes:
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
 
 
 
 

 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.
Sep 12 2006
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=308






I could've sworn C didn't have any kind of properties on built-in types.


-- 
Sep 13 2006
parent Don Clugston <dac nospam.com.au> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=308
 
 
 
 
 

 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.
Sep 13 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=308






They have different notations, so AFAIC there's no reason to assume that
they're supposed to be the same.


-- 
Sep 14 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=308


bugzilla digitalmars.com changed:

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





Fixed in DMC 0.167.


-- 
Sep 19 2006