In Java I need some hint to declare floating point variable that in all virtual machine run uniquely and show number unique float number in all machine ( mobile machine and PC )
+1
A:
You can use strictfp
keyword for class declaration or variables :
public strictfp class MyFPclass {
// ... contents of class here ...
}
The Java package java.lang.Math class contains these strictfp methods:
public static strictfp double abs(double);
public static strictfp int max(int, int);
public static strictfp long max(long, long);
public static strictfp float max(float, float);
public static strictfp double max(double, double);
public static strictfp int min(int, int);
SjB
2010-04-30 17:28:12
Wow ! new keyword ?!!!!!!
Pureth
2010-04-30 17:31:31
It's been part of the language since JDK 1.2
mdma
2010-04-30 22:11:33
A:
I can suggest 2 classes for this purpose you can think of
- Math.random()
- java.util.Random class
The methods of the Random class often produce random numbers in a more convenient form, but requires creating an object, which sometimes is inconvenient. In constrast, the Math.random() method produces a double value which must sometimes be translated and cast into the form you need it. It's a tradeoff between the globalness of Math.random more directly useful numbers from the Random class.
harigm
2010-04-30 17:31:36