| Author |
round method
|
sarathy rambha
Greenhorn
Joined: Mar 26, 2003
Posts: 2
|
|
Hi, I see compilation while compiling below program. But since round(float) returns int, I am not sure why it thinks return type is double. float ddd = 3.5; int j = Math.round(ddd); Math1.java:84: possible loss of precision found : double required: float float ddd = 3.5;
|
 |
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35446
|
posted

0
|
|
The message is talking about the first line of code, not the second. "3.5" is a double, and it gets assigned to a float.
|
Android apps – ImageJ plugins – Java web charts
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6603
|
|
|
The Math class is not part of the exam by the way. As for the error Ulf is right, its on the first line
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12956
|
|
For float literals, you need to append a letter f to the number, like this: float ddd = 3.5f;
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: round method
|
|
|