Skip to main content
gamedev.net
🔒 Locked

NumberFomatException In Java

Started by SKATIN_HARD 3 replies 250+ views
Original Post
SKATIN_HARD
SKATIN_HARD
hey all. I have been getting a NumberFormatException thrown in java when I try to multiply something like 5.50 * .06 (The .06 would be used to find sales tax on the first amount) I don''t know why I am getting this exception. I tried double and float and each one works the same- they both still throw the exception. so does anybody know what I need to do to fix this? so I will be able to multiply currency?? thanks for any help.
clum
clum
More likely, you are getting the NumberFormatException thrown when you try to convert an illegally typed string into a number.

Zorx (a Puzzle Bobble clone)
Discontinuity (an animation system for POV-Ray)
Zorx (a Puzzle Bobble clone)Discontinuity (an animation system for POV-Ray)
Raghar
Raghar
Try 5.5 * 0.06
Arild Fines
Arild Fines
You''re not really supposed to use floating point numbers to represent monetary values.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Matei
Matei
You''re not getting the exception because you''re multiplying two numbers, you''re getting it because you''re trying to convert a string to a number somewhere and failing. Look at the line that the exception occurs on.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.