Convert from std::vector<double> to std::vector<int>

P

Pete Becker

Kurt said:
Fine, I misdescribed it as casting instead of implicit conversion.

No, you criticized what I said based on misunderstanding the terms that
I used.
You
are still converting it from one type to another that cannot support the
same values (3.6 to an int will not give you 3.6 obviously).

And 1/3 does not give you .3333 obviously. Where's the warning for this?
If I'm
going to do something that loses information, I personally prefer to
have something explicitly describing that (like a static_cast<>).

Okay, so instead of

int i = 1/3;

you advocate writing

int i = static_cast<int>(1/3);

so that you're explicitly describing it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top