Results 1 to 3 of 3
- 10-14-2008, 08:05 PM #1
Member
- Join Date
- Aug 2008
- Posts
- 58
- Rep Power
- 0
[SOLVED] Problem hadling number(money) > 214,74,83,647.99
Hello,
How do I suppose to handle number(money) > 214,74,83,647.99
Presently doing following:-
but it gives numberformat errors for value exceding 214,74,83,647.99 :(
Input ....Java Code:private static void doIt(int num) { if (num >= 1000000000) { String temp = "" + num; System.out.println("temp :" + temp); //break it... String temp2 = temp.substring(0, (temp.length() - 7)); String temp3 = temp.substring(temp.length()-7); int num1 = Integer.parseInt(temp3); num = Integer.parseInt(temp2); //... System.out.println("temp After break:" + temp2); System.out.println("Num now:" + num); System.out.println("Rem Num now:" + num1); //' do stuffs //.... } }
Java Code:BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); String input = ""; while(true){ try { System.out.print("\nEnter number (Type \'END\' to exit) :"); input = br.readLine(); //check exit cond... if(input.equalsIgnoreCase("END"))break; System.out.println("You Entered: " + input); doIt(Integer.parseInt(input)); } catch(Exception e) { e.printStackTrace(); }}
Thanks for any clue...Last edited by playwin2; 10-14-2008 at 08:08 PM.
- 10-14-2008, 08:15 PM #2
Please post the full text of the error message with your question.
It has the line number where the error occured.
What data type are you storing the value in? What is the maximum value that the data type will hold?
For example a byte can only hold 256 different values.
- 10-14-2008, 09:32 PM #3
Member
- Join Date
- Aug 2008
- Posts
- 58
- Rep Power
- 0
Ah! Thank you so much Norm, I just forgot int can only hold (2 to the power 31 -1).
Ooops!
You see, I was converting an earlier VB6 routine into Java; In VB the data type was Variant, here I'm using int, so it's turned out that I need to break the data here before converting it.
Thanks again, :) Problem solved.
Similar Threads
-
Using double for money is a sin
By fishtoprecords in forum New To JavaReplies: 3Last Post: 11-28-2008, 07:05 AM -
Money Conversion - Proofreading pls?
By javanewbie in forum New To JavaReplies: 5Last Post: 08-17-2008, 01:40 PM -
Java Developers - Want more money? Better Career prospects? Chance to be DV Cleared?
By MNoone in forum Jobs OfferedReplies: 1Last Post: 08-09-2008, 12:10 PM -
Money to Words
By javanewbie in forum New To JavaReplies: 2Last Post: 06-30-2008, 04:27 AM -
Problem calling classes to flip coin x number of times and record heads or tails
By adlb1300 in forum New To JavaReplies: 2Last Post: 11-11-2007, 08:07 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks