Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8047449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:06:07+00:00 2026-06-05T06:06:07+00:00

This is my javascript code : var dsum = 0.0; $.each($(#Report tbody tr), function

  • 0

This is my javascript code :

var dsum = 0.0;
$.each($("#Report tbody tr"), function () {
    var x = 0.0;

    if ($(this).find("td:eq(3) div").html() != " ")
        x = parseFloat($(this).find("td:eq(3) div").html().replace(/,/g, ""));

    dsum += x;

});

var csum = 0.0;

$.each($("#Report tbody tr"), function () {
     var x = 0.0;
     if ($(this).find("td:eq(4) div").html() != " ")
         x = parseFloat($(this).find("td:eq(4) div").html().replace(/,/g, ""));
         csum += x;

});


var  lastEvenRow=$("#Report").find("tr:last").hasClass('erow');
$("<tr id='LastRow'><td colspan='3' style='border-top: 1px solid #DDDDDD;'><div style='padding:5px;text-align:right;'>Total :</div></td><td style='text-align:center;height:22px;border-top: 1px solid #DDDDDD;'><div style='padding:5px;'>" + dsum.toString(10).replace( /(\d)(?=(\d\d\d)+(?!\d))/g , "$1,") + "</div></td><td style='text-align:center;border-top: 1px solid #DDDDDD;'><div style='padding:5px;'>" + csum.toString(10).replace( /(\d)(?=(\d\d\d)+(?!\d))/g , "$1,") + "</div></td><td style='text-align:center;border-top: 0px solid #DDDDDD;'><div style='padding:5px;border-top: 1px solid #DDDDDD;'>" + (dsum > csum ? (dsum - csum).toString(10).replace( /(\d)(?=(\d\d\d)+(?!\d))/g , "$1,") : "&nbsp;") + "</div></td><td style='text-align:center;'><div style='padding:5px;'>" + (csum >= dsum ? (csum - dsum).toString(10).replace( /(\d)(?=(\d\d\d)+(?!\d))/g , "$1,") : "&nbsp;") + "</div></td></tr>").appendTo("#Report tbody");
if(lastEvenRow==false)
    $("#LastRow").addClass("erow");

enter image description here

As I mentioned in the picture , i think the result must be something like 104,889.01 but , as you see , It is Incorrect value

Is there any body out there to help me ?
Sorry about my bad English syntax(I am new in English)

UPDATE1 :

1318114.01 – 1213225 must be 104889.01 , so why javascript return 104889.01000000001?!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:06:09+00:00Added an answer on June 5, 2026 at 6:06 am

    It happens because it works with convertions from binary to decimal, then we have aproximations, whose result on big floating numbers. See:

    var i = 1;//1
    i += .1;//1.1
    i += .1;//1.2000000000000002
    

    You can try an own aproximation:

    var result = Math.round((1318114.01-1213225)*1000)/1000;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Javascript code: var idJS; $('.disp').click(function () { idJS = $(this).attr(id);
I have this javascript code <Script> function getGroupId(){ var group=document.getElementById(selectedOptions).value; var groupFirstLetter=group.substring(2); } </Script>
This is my JavaScript code: <script> function change(name){ var element = document.all.name.value; } </script>
Check out this piece of JavaScript code: (function (w, d) { var loader =
I'm creating a HTML Canvas object using this javascript code: var Canvas = document.createElement(canvas);
This is my javascript code: var num1; function press_Button(){ num1 = 3; } Then
I have this javascript code: $(document).ready(function() { var leftHeight = $('#maincontent').height(); $('#sidemenu').css({'height':leftHeight}); }); This
I have this JavaScript code: <script type=text/javascript> function timeMsg() { var t=setTimeout(doRedirect(),10000); } function
I have this javascript code: $(function(){ var currentCarouselItem = 1; //set carousel to first
What is this JavaScript code doing here, specifically the while loop: function setAjaxLinks(){ var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.