0

So, I'm trying to shift the comma of an int/long like 37800 by dividing it by e.g. 1000, and saving this then into a float.

float shift;
shift = 37800/1000;

As a result I get 37.0 in this example.

What is happening there? Why do they get deleted?

Baddy
  • 1
  • 1
    Integer division truncates. Promote at least one of the operands to a float to perform floating point division: `shift = 37800/1000f;` – Unmitigated Jul 26 '20 at 14:43
  • 2
    Does this answer your question? [Integer division: How do you produce a double?](https://stackoverflow.com/questions/3144610/integer-division-how-do-you-produce-a-double) - Also applies to float – WJS Jul 26 '20 at 14:44

0 Answers0