两个整数的目标c划分 [英] Objective c division of two ints
本文介绍了两个整数的目标c划分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图通过在程序中除以两个int
来产生一个浮点数.这是我期望的:
I'm trying to produce a a float by dividing two int
s in my program. Here is what I'd expect:
1/120 = 0.00833
1 / 120 = 0.00833
这是我正在使用的代码:
Here is the code I'm using:
float a = 1 / 120;
但是,它没有给我我期望的结果.当我打印出来时,我得到以下信息:
However it doesn't give me the result I'd expect. When I print it out I get the following:
inf
推荐答案
执行以下操作
float a = 1./120.
这篇关于两个整数的目标c划分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文