Re: Funny issue with casting double to ulong

2017-07-04 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 12:32:26 UTC, Patrick Schluter wrote: 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

Re: Funny issue with casting double to ulong

2017-07-04 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 00:35:10 UTC, H. S. Teoh wrote: On Mon, Jul 03, 2017 at 07:13:45AM +, 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

Re: Funny issue with casting double to ulong

2017-07-03 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 03, 2017 at 07:13:45AM +, 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

Re: Funny issue with casting double to ulong

2017-07-03 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 3 July 2017 at 05:38:56 UTC, Era Scarecrow wrote: On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: 6.251 has no perfect double representation. It's real value is: I almost wonder if a BCD, fixed length or alternative for floating point should be an option... Either

Re: Funny issue with casting double to ulong

2017-07-03 Thread via Digitalmars-d-learn
On Monday, 3 July 2017 at 04:06:23 UTC, Saurabh Das wrote: On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: On Monday, 3 July 2017 at 03:50:14 UTC, Saurabh Das wrote: [...] 6.251 has no perfect double representation. It's real value is: 6.215099962483343551867E0 Hence

Re: Funny issue with casting double to ulong

2017-07-03 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 03, 2017 at 05:38:56AM +, Era Scarecrow via Digitalmars-d-learn wrote: > On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: > > 6.251 has no perfect double representation. It's real value is: > > I almost wonder if a BCD, fixed length or alternative for floating > point

Re: Funny issue with casting double to ulong

2017-07-02 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: 6.251 has no perfect double representation. It's real value is: I almost wonder if a BCD, fixed length or alternative for floating point should be an option... Either library, or a hook to change how the FPU works since doubles are

Re: Funny issue with casting double to ulong

2017-07-02 Thread Saurabh Das via Digitalmars-d-learn
On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: On Monday, 3 July 2017 at 03:50:14 UTC, Saurabh Das wrote: [...] 6.251 has no perfect double representation. It's real value is: 6.215099962483343551867E0 Hence when you cast to ulong after the product by 10_000, this is

Re: Funny issue with casting double to ulong

2017-07-02 Thread Basile B via Digitalmars-d-learn
On Monday, 3 July 2017 at 03:50:14 UTC, Saurabh Das wrote: Consider this snippet: void main() { import std.stdio; auto a = 6.2151; auto b = a * 1; auto c = cast(ulong)b; writeln("a: ", typeof(a).stringof, " ", a); writeln("b: ", typeof(b).stringof, " ", b);

Funny issue with casting double to ulong

2017-07-02 Thread Saurabh Das via Digitalmars-d-learn
Consider this snippet: void main() { import std.stdio; auto a = 6.2151; auto b = a * 1; auto c = cast(ulong)b; writeln("a: ", typeof(a).stringof, " ", a); writeln("b: ", typeof(b).stringof, " ", b); writeln("c: ", typeof(c).stringof, " ", c); auto x =