0

Why the pow function act like this?, shouldn't the computer consider any integer for example the number 3 as float like this 3.000etc? why it produce different results?

IDE Screenshot

1 Answer 1

0

There is nothing strange in the results, everything depends on the exponent that is different in two cases, as you see n1 and n4 are equal, also are equal n2 and n3, this is because we have two types of division, the entire division, and a division between numbers of float type. The division between two integers in C differs from the rest of modern languages, here we are left with the integer part of the quotient and we eliminate the decimal part (k becomes integer and loses its decimal part), so if we say:

int a = 3/4;
then  
a = 0;

The division between float type numbers is as expected, with an integer part and a decimal part, which corresponds to the values n2 and n3.

1
  • Very well, thank you
    – Sengo
    Commented Mar 19, 2018 at 7:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .