86399 / 3600 = 23.999722222222222222222222222222

I need this whole number, or at least to 10 places or so.

How can I make the entire number show in Java?

I need this whole number, or at least to 10 places or so.

How can I make the entire number show in Java?

Do more with

EXPERT OFFICE^{®} is a registered trademark of EXPERTS EXCHANGE^{®}

If 'i' is integer, then the whole part

i = 86399 / 3600

then the remainder (non-integer) is (86399 / 3600) - i

or remainder is -i + 86399 / 3600

[parens now needed but for clarity]

if i is not integer then use integer function (convert to) on the first division process

public class Fraction {

public static double digits(double d, int places) {

return (long)(d*Math.pow(10,place

}

public static double digits(double d, long places) {

return (long)(d*Math.pow(10,place

}

public static float digits(float d, int places) {

return (int)(d*Math.pow(10,places

}

public static float digits(float d, long places) {

return (int)(d*Math.pow(10,places

}

}

Usage:

* double x = 86399 / 3600;

* System.out.print( Fraction.digits(x,10) ); // Fraction.digits(double, number of places);

* // will output the double as : 23.9997222222 (10 placess)

Usage:

* float y = 86399 / 3600;

* System.out.print( Fraction.digits(f,10) ); // Fraction.digits(float, number of places);

* // will output the float as : 23.9997222222 (10 placess)

3.2.1 Integral Types and Values

The values of the integral types of the Java Virtual Machine are the same as those for the integral types of the Java language (§2.4.1):

For byte, from -128 to 127 (-27 to 27-1), inclusive

For short, from -32768 to 32767 (-215 to 215-1), inclusive

For int, from -2147483648 to 2147483647 (-231 to 231-1), inclusive

For long, from -9223372036854775808 to 9223372036854775807 (-263 to 263-1), inclusive

For char, from 'u0000' to 'uffff'; char is unsigned, so 'uffff' represents 65535 when used in expressions, not -1

3.2.2 Floating-Point Types and Values

The largest positive finite floating-point literal of type double is 1.79769313486231570e+308. The smallest positive nonzero floating-point literal of type double is 4.94065645841246544e-324.

## Premium Content

You need an Expert Office subscription to comment.Start Free Trial