What is a concise way to test if floating point value is integral?

Paul Jurczak pauljurczak at yahoo.com
Thu Aug 29 01:07:31 PDT 2013


On Thursday, 29 August 2013 at 07:51:40 UTC, Jonathan M Davis 
wrote:
[..]
> as any integral value in a float will fit in an
> int.
[..]

Will it? Most of them will not fit, but cast to int produces 
nonsensical value anyway as in this example:

cast(int)float.max

With to!int you get a proper warning.


More information about the Digitalmars-d-learn mailing list