English 中文(简体)
2. 地面功能,以浮动和双重价值
原标题:Floor function to float and double values
  • 时间:2012-04-20 09:32:24
  •  标签:
  • java
  • math

How to apply floor function to float or double values to get integer.I got double Value:4.4497083717E10 float Value:4.4497084E10 out of my function.I got floor values as Floor of double:4.4497083717E10 Floor of float:4.4497084416E10.Is there a possibility that floor results in a integer??

问题回答

。 底线是否会导致愤怒?

http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html

That said, the documentation for the method declares that the returned value is equal to an integer. So simply casting the returned result to an int will always give you the output you expect.

(假设你的结果是多种多样的。) www.un.org/spanish/ecosoc 可持有<代码>int可代表的较大数目。 http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.1.3”rel=“nofollow” 技术细节上的微量减量换算。 您不妨对您的数据进行约束,以确保其始终能够转换为<代码>int。

4.4497083717E10过于庞大,不能成为<条码>int,你必须投到<条码>。

长期以来,这种双重做法的整部分与<>Math.底对可长期代表的价值加以表述。 i.e.

long l = (long) Math.floor(4.4497083717E10);

这与

long l = (long) 4.4497083717E10;

System.out.println((int) Math.floor(4.4497083717E10));
System.out.println((long) Math.floor(4.4497083717E10));
System.out.println((long) 4.4497083717E10);

印刷

2147483647   -- due to an overflow
44497083717
44497083717




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签