[Issue 4445] New: roundTo!ubyte(255.0) throws

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 10 12:20:03 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4445

           Summary: roundTo!ubyte(255.0) throws
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: dsimcha at yahoo.com


--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2010-07-10 12:19:58 PDT ---
Seems like an off-by-one error in checking the bounds.

import std.stdio, std.conv;

void main() {
    auto foo = cast(ubyte) roundTo!uint(255.0);
    writeln(foo);  // 255:  Works.

    auto bar = roundTo!ubyte(254.0);
    writeln(bar);  // 254:  Works.

    auto baz = roundTo!ubyte(255.0);  // Throws
}

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


More information about the Digitalmars-d-bugs mailing list