Results 1 to 8 of 8
Thread: Conversions
- 05-25-2012, 04:15 AM #1
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
- 05-25-2012, 04:45 AM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Re: Conversions
If your big number is an integer number and you are using the BigInteger class you can simply use the "%, d" as the format.
Java Code:System.out.printf("%, d", new BigInteger("640237370528000"));Website: Learn Java by Examples
- 05-25-2012, 04:56 PM #3
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
Re: Conversions
the users enter a number. its not a fixed number. i want to know how to use conversions so there is a comma in every thousand separator
- 05-25-2012, 05:00 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
Re: Conversions
Have you actually read the previous reply?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 05-25-2012, 05:11 PM #5
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
Re: Conversions
yes i did, i used that. i got java.util.illegalformatconversionexception
- 05-25-2012, 05:21 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
- 05-25-2012, 05:36 PM #7
Member
- Join Date
- May 2012
- Posts
- 15
- Rep Power
- 0
Re: Conversions
this is my code:
import java.io.*;
import java.util.Scanner;
import java.lang.*;
import type.lib.ToolBox;
public class eCheck03D
{
public static void main(String[] args)
{
PrintStream out = System.out;
Scanner in = new Scanner(System.in);
out.print("Enter an integer ... ");
int integer = in.nextInt();
double f = ToolBox.factorial(integer);
out.print(integer + "! = ");
out.printf("%.0f%, d", f);
double root = Math.cbrt(integer);
out.println("");
out.print("Cubic Root of 18 = ");
out.printf("%.0f" , root);
}
}
I have JDK 7
- 05-25-2012, 05:40 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,394
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
[SOLVED] Base conversions
By rlzyoner in forum New To JavaReplies: 3Last Post: 12-10-2008, 12:40 PM -
Conversions
By apfroggy0408 in forum New To JavaReplies: 3Last Post: 03-04-2008, 11:59 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks