[Issue 3520] std.numeric.CustomFloat horribly broken

2015-06-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=3520

Andrei Alexandrescu and...@erdani.com changed:

   What|Removed |Added

Version|2.036   |D2

--


[Issue 3520] std.numeric.CustomFloat horribly broken

2010-06-15 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3520


Brad Roberts bra...@puremagic.com changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 CC||bra...@puremagic.com
 Resolution||FIXED


--- Comment #6 from Brad Roberts bra...@puremagic.com 2010-06-15 02:08:50 PDT 
---
fixed in 2.047

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3520] std.numeric.CustomFloat horribly broken

2010-05-08 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3520



--- Comment #5 from Rob Jacques sandf...@jhu.edu 2010-05-08 10:20:39 PDT ---
Another issue: float.infinity isn't converted properly.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3520] std.numeric.CustomFloat horribly broken

2010-04-08 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3520


Rob Jacques sandf...@jhu.edu changed:

   What|Removed |Added

 CC||sandf...@jhu.edu
   Severity|normal  |regression


--- Comment #3 from Rob Jacques sandf...@jhu.edu 2010-04-08 09:30:55 PDT ---
There seems to be an additional problem with custom float. In DMD 2.039 and
2.042 it doesn't compile. I've developed a hack/patch around this issue.

For example:
CustomFloat!(1, 5, 10) temp;

Error: this for signfractionexponent needs to be type CustomFloat not type
CustomFloat!(1,5,10)
Error: struct std.numeric.CustomFloat!(1,5,10).CustomFloat member
signfractionexponent is not accessible
Error: template instance std.numeric.CustomFloat!(1,5,10) error instantiating

I've been able to reduce the code to a test case

struct CustomFloat(
bool signBit,   
uint fractionBits,  
uint exponentBits,
//uint bias = (1u  (exponentBits - 1)) - 1// This is the problem
CustomFloatFlags flags = CustomFloatFlags.all
)
{

float foo;
float bar() { return foo;}
F get(F)() { return 1; }
}

however, when I try this as independent test case, the bug isn't reproduced. 

As a quick patch I've move bias from a template parameter to the struct body as
an enum:

struct CustomFloat(
bool signBit,   // allocate a sign bit? (true for float)
uint fractionBits,  // fraction bits (23 for float)
uint exponentBits,
//uint bias = (1u  (exponentBits - 1)) - 1
CustomFloatFlags flags = CustomFloatFlags.all)
{
enum bias = (1u  (exponentBits - 1)) - 1;
...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3520] std.numeric.CustomFloat horribly broken

2010-04-08 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3520



--- Comment #4 from Rob Jacques sandf...@jhu.edu 2010-04-08 10:49:06 PDT ---
The bit layout of custom float is not IEEE compliant and can't be used to
represent half, float nor double types.

Here's the correct layout
private mixin(bitfields!(
  uint, fraction, fractionBits,
  uint, exponent, exponentBits,
  bool,   sign,   signBit));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3520] std.numeric.CustomFloat horribly broken

2009-11-16 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3520


Andrei Alexandrescu and...@metalanguage.com changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||and...@metalanguage.com
 AssignedTo|nob...@puremagic.com|and...@metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 3520] std.numeric.CustomFloat horribly broken

2009-11-16 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=3520



--- Comment #1 from David Simcha dsim...@yahoo.com 2009-11-16 20:15:34 PST ---
Okay, I've gotten a good start on debugging this by pragma'ing the bitfield
code and pasting it in to temporarily get rid of the mixin.  The assert failure
is in setting the exponent:

void exponent(uint v){
assert(v = exponent_min);
assert(v = exponent_max);  // FAILS
signfractionexponent = cast(typeof(signfractionexponent))
((signfractionexponent  ~49152U) | ((cast(typeof(signfractionexponent)) v 
14U)  49152U));
}


The problem appears to be overflow in the following code in opAssign:

exponent = cast(typeof(exponent_max))
(value.exponent + (bias - value.bias));

If the result is negative, we get overflow.  Instead, this should probably
result in a denormal or something.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---