Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17625

Casting or type conversion question

$
0
0

Hello,

can someone explain me if there are differences in execution speed between following 3:

int a=3;
size_t b=(size_t)a;
size_t b=size_t(a);
size_t b=static_cast<size_t>(a);

I am pretty much sure that there is no difference between #1 and #3. But for #2, doesn't that add an overhead because of the constructor?

And what about following example?

unsigned char* a=aRandomBuffer;
float b=((float*)a)[0];
float b=(reinterpret_cast<float*>(a))[0];

Thanks for any insight!


Viewing all articles
Browse latest Browse all 17625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>