float(i) or (float)i ?

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
binbinhfr
Posts: 78
Joined: May 9th, 2019, 10:57 pm

float(i) or (float)i ?

Post by binbinhfr » April 2nd, 2020, 7:15 am

concerning basic types like int, float, etc... when I have to specify conversion, I always ask myself if the notation float(i) is totally equivalent to (float)i in term of compiling efficiency ?

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: float(i) or (float)i ?

Post by albinopapa » April 2nd, 2020, 8:33 am

Means the same thing.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: float(i) or (float)i ?

Post by albinopapa » April 2nd, 2020, 8:34 am

Since C++ has constructors, int( i ) is valid whereas last time I tried that in C the compiler gave me errors.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

binbinhfr
Posts: 78
Joined: May 9th, 2019, 10:57 pm

Re: float(i) or (float)i ?

Post by binbinhfr » April 2nd, 2020, 9:52 am

ok thx, I was just curious.

Post Reply