samedi 10 septembre 2022

Why do I get int value after typecasting but decimal value is in bracket?

I'm very familiar with c++ but Today I notice something,

float a=(float)5/2; //this gives 2.5, its okay
float b=(float)(5/2); //this gives 2, why?

Please can you name this topic and any answer will help me.

Aucun commentaire:

Enregistrer un commentaire