fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Ideone{
  8.  
  9. static double factor = 1;
  10. static final long INT_MASK = 0xffffffffL;
  11.  
  12. public static void main(String []args){
  13. System.out.println("Hello World");
  14. System.out.println("MAXIMO:" + getDouble(Integer.MAX_VALUE));
  15. System.out.println("MINIMO:" + getDouble(Integer.MIN_VALUE));
  16. System.out.println("MAXIMO:" + getDoubleUsingLong(Integer.MAX_VALUE));
  17. System.out.println("MINIMO:" + getDoubleUsingLong(Integer.MIN_VALUE));
  18. System.out.println("MINIMO:" + getDoubleUsingLong(-1));
  19. System.out.println("MINIMO:" + getDoubleUsingLong(1));
  20. System.out.println("MINIMO:" + getDoubleUsingLong(0));
  21.  
  22.  
  23. }
  24.  
  25. static public double getDouble(int pulses)
  26. {
  27. double result;
  28.  
  29. result = (double) pulses * factor;
  30.  
  31. return result;
  32. }
  33.  
  34. static public double getDoubleUsingLong(int pulses)
  35. {
  36. double result;
  37.  
  38. return toLong(pulses) * factor;
  39. }
  40.  
  41. /**
  42.   * Returns the value of the given {@code int} as a {@code long}, when treated as unsigned.
  43. */
  44. public static long toLong(int value) {
  45. return value & INT_MASK;
  46. }
  47. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
Hello World
MAXIMO:2.147483647E9
MINIMO:-2.147483648E9
MAXIMO:2.147483647E9
MINIMO:2.147483648E9
MINIMO:4.294967295E9
MINIMO:1.0
MINIMO:0.0