Bug 308 – Documentation of float.max_exp, min_exp is misleading

Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-08-24T07:46:00Z
Last change time
2014-02-15T13:22:08Z
Assigned to
bugzilla
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2006-08-24T07:46:40Z
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);
Comment #1 by smjg — 2006-09-09T18:50:38Z
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?
Comment #2 by aldacron — 2006-09-13T01:55:15Z
[email protected] wrote: > http://d.puremagic.com/issues/show_bug.cgi?id=308 > > > [email protected] changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |[email protected] > > > > > ------- Comment #1 from [email protected] 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.
Comment #3 by smjg — 2006-09-13T05:29:10Z
I could've sworn C didn't have any kind of properties on built-in types.
Comment #4 by aldacron — 2006-09-13T09:35:22Z
[email protected] wrote: > http://d.puremagic.com/issues/show_bug.cgi?id=308 > > > > > > ------- Comment #3 from [email protected] 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.
Comment #5 by smjg — 2006-09-14T17:52:31Z
They have different notations, so AFAIC there's no reason to assume that they're supposed to be the same.
Comment #6 by bugzilla — 2006-09-19T15:27:21Z
Fixed in DMC 0.167.