D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4445 - roundTo!ubyte(255.0) throws
Summary: roundTo!ubyte(255.0) throws
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: Shin Fujishiro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-10 12:19 UTC by David Simcha
Modified: 2010-11-16 12:57 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2010-07-10 12:19:58 UTC
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
}
Comment 1 Shin Fujishiro 2010-11-16 12:57:37 UTC
Fixed: http://www.dsource.org/projects/phobos/changeset/2167