Help, how to extract the integer part
Solved
Thinathenet
Posted messages
23
Status
Member
-
Thinathenet Posted messages 23 Status Member -
Thinathenet Posted messages 23 Status Member -
Hello,
How can I extract the integer part of a real number using Java, and thank youuu :) !!!
How can I extract the integer part of a real number using Java, and thank youuu :) !!!
2 answers
-
Hello,
The primitive that represents real numbers is "double".
So, to extract the integer "int" from this real number, just do as in this example:
double d = -12.91; System.out.println("d= " + d); int i = (int) d; System.out.println("i= " + i);
The result:d= -12.91 i= -12
Good luck
Being normal is boring... being geek is interesting