www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - direct conversion to integral type for floor, ceil, and friends that

What's the most efficient way to convert a float/double/real to an integer
type with a specified rounding scheme (eg floor/ceil etc)?

Is there anything besides:
int x=floor(1.2); ?
there's also

Because these first convert to floating point representation and then then
the conversion to int happens.

Could we support the following instead:

T floor(T,S)(S x) if (/+insert good template constraits+/) {
//right now just return existing floor and convert to T but later can
provide more efficient direct implementation, so user can start using it
right now.

and friends, modeled after std.conv.to.
May 28 2013