Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Given a floating-point number in Java, output the integer part and decimal part of the number. There are roughly several ways.
Given a floating-point number in Java, output the integer part and decimal part of the number. There are roughly several ways.
Tell me two things I know:

1。

Floating point number a = 3.14;

System.out.println ("integer part:"+(int) a);

System.out.println ("fractional part:" +a% 1)

2。 Converts a floating-point number to a string, and then uses the. The first part is an integer and the second part is a decimal.