473,652 Members | 3,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem when adding decimal values with parseFloat

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

var first = 0.1;
var second = 0.2;

var tot = parseFloat(firs t) + parseFloat(seco nd);

i am expecting result as : 0.3

But it is giving result as : 0.3000000000000 0004


Please let me know if anyone know the solution.
Apr 26 '12 #1
3 1513
Dormilich
8,658 Recognized Expert Moderator Expert
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
roshan ban
21 New Member
try parseDouble(tot ); at the end of your result
Apr 29 '12 #3
Dormilich
8,658 Recognized Expert Moderator Expert
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
3592
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 can't figure out why the design is so that the DataRow "alters" the value entered. In my application a decimal column in a row of a specific table has a fix number of decimal places according to certain premises. The
2
1914
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 item I press buttton with ibNewDep_Click event. After that the grid is in edit state and I can modify new item, it has some text, set as default - "<nowy wydział>". But - this is the weirdness - when I add some text following the default value
1
1487
by: RN | last post by:
Hi. I used this article to add a template column to a datagrid that is entirely created with code: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatingtemplatesprogrammaticallyindatagridcontrol.asp It works fine except for one thing. My template column needs a field in the recordset that binds to the datagrid. The template column is an HTML radio button where the value of the radio button needs...
0
1095
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 available. The folder may have been moved or deleted, or network problems may be preventing a connection to the server.' although the folters are perfectly there. I really need to add these particular folders, how can I solve this?
7
2003
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 subform(to frmInvoices) sfrmDetails via qryDetails. Relationship built between tblClients/tblInvoices/tblDetails by ClientID. Relationship between tblInvoices/tblDetails by InvoiceID. All works fine if
2
2291
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 but a modal error message appear: " Wizard Form / An unexpected error has occurred. / Error Message: Object reference not set to an instance" and when I click OK button, the whole
1
1291
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 total and shows in the footer of the grid. I wanna get exact 2.56789 to show. I tried converting it to decimal but still it rounds it off. Any help will be appreciated. Sub ComputeSum(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
6
1068
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 work
3
2631
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 field. The command button "cmdProcess" is supposed to add some fields (customer no, invoice date, grand total (as receivable), currency etc) to a table which keeps track of customer transactions. However, the decimals of grand total field is rounded...
0
2187
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. This is done in a for loop with custom positioning logic (basically this: start at int _top = 0, set the Top property of the current control to _top, add to _top the Height of the current control). I finish this method (the one that the adding...
0
8367
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8589
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.