473,395 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem when adding decimal values with parseFloat

When i am adding the two decimal values using with java script

var first = 0.1;
var second = 0.2;

var tot = parseFloat(first) + parseFloat(second);

i am expecting result as : 0.3

But it is giving result as : 0.30000000000000004


Please let me know if anyone know the solution.
Apr 26 '12 #1
3 1503
Dormilich
8,658 Expert Mod 8TB
there is no solution. that is a limitation of floating point arithmetics. all you could do is round the value to a desired number of digits.
Apr 26 '12 #2
try parseDouble(tot); at the end of your result
Apr 29 '12 #3
Dormilich
8,658 Expert Mod 8TB
parseDouble() is not a built-in JavaScript function.
Apr 29 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Carl G | last post by:
I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places. It looks like the Get property returns System.Decimal.Zero, but why???? I...
2
by: Tomek R. | last post by:
Hello ! I've got weird problem when adding new datagrid item. Here is the situation: my grid dgDeps is binded to DepartmentList arraylist, stored in Session between round-trips.. To add new...
1
by: RN | last post by:
Hi. I used this article to add a template column to a datagrid that is entirely created with code: ...
0
by: james henderson | last post by:
When I start up My IDE (visual studio 2003) my project references to the web projects were disappeared. When I want to readd them I receive the error message 'Documents in this folder are not...
7
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on...
2
by: newsgroup.poster | last post by:
Hello, I'm encounterring the following problem when I try to add object datasource to my C# project: - the wizzard form open - I choose object, then click on next - the next screen display...
1
by: methexandude | last post by:
Hi, I'm populating a datagrid with values and adding one of the columns to get a total. It adds up correctly but rounds off the values. For example if the total is 2.56789 it makes it three as a...
6
by: jaz215 | last post by:
when i add data it doesn't seem to go into the recordset immediately i have to close the program and reopen before i can see the newly added data. i tried refresh and requery but it doesn't seem to...
3
by: Celal | last post by:
Hi, I couldn't get around a problem about decimal rounding up when adding a record to a table from a form by programming a button. I have an invoice form where the grand total is a calculated text...
0
by: arbe81 | last post by:
I have a problem with ScrollControlIntoView() in .NET 2.0: I have a UserControl that holds a Panel which is set to AutoScroll. To this panel, I add a list of Controls so the panel needs to scroll....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.