Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 21994

Why I have a wrong result in C after storing a division of integers in a floating variable? [duplicate]

$
0
0

This question already has an answer here:

I am working with STM32 and GCC Compiler and I make the following division:

uint8_t w, h;
w=2;
h=5;
float test = (w * h) / 8;

and the result is test=1

Why am I wrong? I cannot understand this behavior.

Could someone explain me the reason?


Viewing all articles
Browse latest Browse all 21994

Trending Articles



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