JBox-2d中的"f"是什么? [英] What is the 'f' used for in JBox-2d?

查看:93
本文介绍了JBox-2d中的"f"是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它似乎用在引擎的值声明中,但是JBox-2D的文档没有解释这个单位"是什么.示例:

It seems to be used in value declarations in the engine but the documentation of JBox-2D does not explain what this 'unit' is. Example:

float x = 20.0f //<-- this 'f'

FixtureDef fixDef = new FixtureDef();
fixDef.shape = shape;
fixDef.density = 0.0f; //<-- this 'f'
fixDef.friction = 0.9f; //<-- this 'f'

是什么?如果确实是一个单位,它相对于什么?它对引擎有什么好处?

What is it? If it is indeed a unit, what is it relative to? What benefit does it have for the engine?

它对引擎有什么用?使用浮点数而不是双精度数有什么好处吗?

What use does it have for the engine? Is there any benefit to using a float opposed to a double?

推荐答案

没有单位,f表示数字是float.

It is no unit, f indicates that the number is a float.

例如,如果仅编写0.1,则会出现错误,因为0.1将被解析为double值.编译器需要以下指令:该值是浮点数.这就是f的作用.

If you just write 0.1 for example, you will get an error because 0.1 will be parsed as a double value. The compiler needs the instruction that the value is desired a float. That's what's the f for.

请参见 http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

这篇关于JBox-2d中的"f"是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆