Funny issue with casting double to ulong

Patrick Schluter via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 4 05:32:26 PDT 2017


On Tuesday, 4 July 2017 at 00:35:10 UTC, H. S. Teoh wrote:
> On Mon, Jul 03, 2017 at 07:13:45AM +0000, Era Scarecrow via 
> Digitalmars-d-learn wrote:
>> On Monday, 3 July 2017 at 06:20:22 UTC, H. S. Teoh wrote:
> [...]
>> > I don't think there's a way to change how the FPU works -- 
>> > the hardware is coded that way and can't be changed.  You'd 
>> > have to build your own library or use an existing one for 
>> > this purpose.
>> 
>>  It's been a while, i do recall there was BCD options, 
>> actually found
>> a few of the instructions; However they are more on 
>> loading/storing
>> the value, not on working strictly in that mode. Last i 
>> remember
>> seeing references to BCD work was in 2000 or so.
>> 
>>  I'll have to look further before i find (or fail to find) all 
>> that's
>> BCD related. Still if it IS avaliable, it would be an x87 only 
>> option
>> and thus wouldn't be portable unless the language or a library 
>> offered
>> support.
>
> Wow, that brings back the memories... I used to dabble with BCD 
> (only a little bit) back when I was playing with 8086/8088 
> assembly language. But I've not heard anything about BCD since 
> that era, and I'm surprised people still know what it is. :-D  
> But all I knew about BCD was in the realm of integer 
> arithmetic. I had no idea such things as BCD floats existed.
>
In times of lore, BCD floats were very common. The Sharp Pocket 
Computer used a BCD float format and writing machine code on them 
confronts one with the format. The TI-99/4A home computer also 
used a BCD float format in its Basic interpreter. It had the same 
properties as the float format of the TI calculators, i.e. 10 
visible significant digits (+ 3 hidden digits) and exponents 
going from -99 to +99. It is only then when I switched to the 
Apple II Applesoft Basic that I discovered the horrors of binary 
floating point numbers.
Since the generalization of arithmetic co-processors does one 
only see binary floats anymore.




More information about the Digitalmars-d-learn mailing list