Best way to convert and apply floor()

Daniele M. gdm85 at iragan.com
Sun Apr 6 01:23:13 PDT 2014


Hello guys/girls,


I have read almost completely the book and I am very much 
interested in D language. However sometimes I have doubts that I 
cannot clearly cut out, thus I thought it would be a good idea to 
ask the community.

For example, is this the best way to perform a conversion + floor?
Input 'x' is a floating point expression that is never big enough 
to justify usage of double or real type, but I picked "real" 
because I noticed that it was the implicit cast type.

auto s = "3.14";
int x = cast(int)floor(to!real(x));
// x == 3

Thanks in advance!
--
   Daniele


More information about the Digitalmars-d-learn mailing list