May 28, 2013 direct conversion to integral type for floor, ceil, and friends that return integer as real | ||||
|---|---|---|---|---|
| ||||
Attachments:
| 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
core.stdc.math.floor{l,f,}
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.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply