lundi 2 janvier 2017

C++11 auto. convert from float to long

Is it possible to convert foo from float to long (and vice versa)?

auto foo = float(1234567891234.1234);
cout << "foo: " << foo << endl;

foo = long(1234567891234.1234);
cout << "foo: " << foo << endl;

The output is always:

foo: 1.23457e+12
foo: 1.23457e+12

Aucun commentaire:

Enregistrer un commentaire