I have a double number and i want to print only the integral part of this number. I was trying to print it using System.out.printf
but i i got an IllegalFormatConversionException
. I tried something like:
A()
{
double x;
//calculate double
System.out.println("%d",x);
}
I know that i can simply print it using System.out.print
but that will print the decimal part too. How can i do this using printf
?
System.out.printf("%.0f",x);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With