BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-17-2008, 10:53 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Oct 2007
Location: montreal
Model: 8100
PIN: N/A
Carrier: rogers
Posts: 70
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Why this NumberFormatException error?

Please Login to Remove!

Anyone know why I'm getting this NumberFormatException error from this 2-line code?

String cNorm = "" + ((1.5 * (NumStat - 1) * 10) - 15);
resultsField.setText(cNorm);

I also tried this but got the same error:

double t = ((1.5 * (NumStat - 1) * 10) - 15);
String cNorm = "" + Double.toString(t);
resultsField.setText(cNorm);

I checked the Sun Java Tutorials and tried all the various methods to convert the calculation to a string but they all give me the same error. I just want to display that result in a text field.

Thanks for any help...
Offline  
Old 07-17-2008, 11:03 PM   #2 (permalink)
Talking BlackBerry Encyclopedia
 
richard.puckett's Avatar
 
Join Date: Oct 2007
Location: Seattle, WA
Model: 9020
PIN: N/A
Carrier: T-Mobile
Posts: 212
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

What is NumStat? What value does it have?
__________________
Do your homework and know how to ask a good question.
Offline  
Old 07-18-2008, 02:57 AM   #3 (permalink)
New Member
 
Join Date: Jul 2008
Model: 8320
OS: 4.2.2.171
PIN: N/A
Carrier: Orange
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

have you tried String.valueOf(integer)
Offline  
Old 07-18-2008, 11:01 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Oct 2007
Location: montreal
Model: 8100
PIN: N/A
Carrier: rogers
Posts: 70
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by richard.puckett View Post
What is NumStat? What value does it have?
Darn it! That may be it. Its an integer between 2 and 8. I'll try changing that to double when I'm home tonight and report back.

Jansongk: yes, I tried that and got the same error.


You guys are great. Thanks a bunch.
Offline  
Old 07-18-2008, 04:16 PM   #5 (permalink)
Thumbs Must Hurt
 
Join Date: Oct 2007
Location: montreal
Model: 8100
PIN: N/A
Carrier: rogers
Posts: 70
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yep, that's what the problem was. NumStat was declared as an integer & I just changed that to double. Works like a charm now. Noobie mistake.

Thanks again richard.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.