views:

82

answers:

3

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
Wow ! new keyword ?!!!!!!
Pureth
It's been part of the language since JDK 1.2
mdma
A: 

Take a look at strictfp here

Oso
A: 

I can suggest 2 classes for this purpose you can think of

  1. Math.random()
  2. 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