为什么我在除以例如 1000000000 时得不到任何小数位呢

huangapple 未分类评论51阅读模式
英文:

Why don't I get any decimal place when dividing by e.g. 1000000000

问题

所以,我试图通过将整数/长整数(如37800)除以1000来移动逗号,然后将结果保存到一个浮点数中。

float shift;
shift = 37800 / 1000;

在这个例子中,我得到了37.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?

huangapple
  • 本文由 发表于 2020年7月26日 22:41:45
  • 转载请务必保留本文链接:https://java.coder-hub.com/63101639.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定