Smart questions
Smart people
 Find A ForumFind An Expert
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Remember Me

Are you a
Computer / IT professional?
Join Tek-Tips now!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Just copy and paste the

#### Feedback

"...I have to add my thanks and appreciation for your wonderful site... People who frequent the site are the two best things - nice and smart..."

#### Geography

Where in the world do Tek-Tips members come from?

#### Tek-Tips Shirts!

 Forum Search FAQs Links Jobs Whitepapers MVPs
 craigward (Programmer) 4 Jul 12 11:57
Hi there,

I am having trouble getting a math function to add to currency values together.

The issue is the rounding, here is a basic example. var c is returning 3761 and it should be 3762.38

I have played with a lot of examples but can't get it working. Is there a simple method out there to achieve the correct calculation?

Thanks for looking.

#### CODE

```<html>

<script language="JavaScript">

function calcvals(){

var a = '3145,8'
var b = '616,58'
var c = parseFloat(a) + parseFloat(b)

}

</script>

</body>
</html> ```
 vacunita (Programmer) 4 Jul 12 12:21
Javascript has no locale settings, so it can't recognize a comma as a decimal separator. Having values that use a comma as a decimal separator will cause issues like the one you are having. That is the actual numbers are being parsed as rounded integers since the comma there is not valid.

#### CODE

```var a = '3145.8'

var b = '616.58' ```

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web &amp; Tech

 craigward (Programmer) 4 Jul 12 12:26
 Thank you

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!