[Issue 20261] CustromFloat.epsilon yields infinity

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 9 09:56:50 UTC 2019


berni44 <bugzilla at d-ecke.de> changed:

           What    |Removed                     |Added
                 CC|                            |bugzilla at d-ecke.de

--- Comment #2 from berni44 <bugzilla at d-ecke.de> ---
Meanwhile I found out, that .epsilon can be really snappish. In some cases it
can only be displayed as denormalized value. If denormalized values are not
supported, epsilon cannot be represented at all. 

For me, the question arises, what to do in such cases.

a) Just not define .epsilon for these types? Might be hard to implement.
b) Use NaN? But what, if NaN is not available?
c) Use the smallest value greater 0 instead? In rare cases, even this value
might not exist. CustomFloat(7,1,CustomFloatFlags.allowDenormZeroOnly |
CustomFloatFlags.nan). Here only +/- 0 and NaN exists.
d) Use 1+epsilon - 1. This leaves the answer to this question to the routine
converting real to CustomFloat. But in some cases 1+epsilon does not exist too,
see above. But if it exists, it's much simpler to construct than epsilon
e) Use return type real? I expect some other trouble with that approach.

I tend to d) + completely prohibiting types, where this doesn't work. These are
stange types that are of no use anyway.


More information about the Digitalmars-d-bugs mailing list