float init 0 request

An home at home.com
Sun Aug 23 04:40:55 UTC 2026


On Saturday, 22 August 2026 at 23:49:35 UTC, claptrap wrote:
> On Saturday, 22 August 2026 at 19:44:51 UTC, Walter Bright 
> wrote:
>> On 8/21/2026 4:22 PM, claptrap wrote:
>>> My argument is that given that NaN doesnt guarantee you will 
>>> get an obvious wrong value,
>>

Agree with you here.

NaN -> wrong value -> time consuming to hunt for bug fix
NaN -> wrong value -> no body read detail of spec/document
NaN -> wrong value -> more compiler flag to work around bug fix

0.0 -> expected value most of the time -> work as expected

If D want to fix, it should give a feature to extend 
float/integer without needing a cast

Not good/Limit
struct ExtendedFloat
{
   float f;
   alias this = f;
}

Something as below so that it does not need cast when assigned 
from a float type
ExtendedFloat extended of float
{
   invariant { value >= 2.0 && value <= 100.0 }
   init => 10.0;
   min => 2.0;
   max => 100.0;
}

ExtendedFloat f1, f2; // default value to 10.0
f1 = 1000.0; // invariant check - error/exception raised - out of 
range
f1 = f2; // no need for invariant check
f1 = float.nan;  // invariant check - error/exception raised - 
out of range




More information about the Digitalmars-d mailing list