www.webdeveloper.com
Results 1 to 4 of 4

Thread: ParseFloat issue

  1. #1
    Join Date
    Mar 2012
    Posts
    41

    ParseFloat issue

    so I have and array assetCost = "350000.00","500000.00" so in a for loop Im trying to do this:

    result += parseFloat(assetCost[rowIndex-1],10).toFixed(2);

    but the problem is that instead of adding is concatenating.

    thanks for your help.

  2. #2
    Join Date
    Jul 2003
    Location
    The City of Roses
    Posts
    2,503
    The only way I can see that happening is if the result variable were a string.
    for(split(//,'))*))91:+9.*4:1A1+9,1))2*:..)))2*:31.-1)4131)1))2*:3)"'))
    {for(ord){$i+=$_&7;grep(vec($s,$i++,1)=1,1..($_>>3)-4);}}print"$s\n";

  3. #3
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    As Jeff said, that happens because your values are primitives of type String, not Number. And that is due to the fact that the method toFixed() transforms again a Number into a String.

    Anyway, toFixed() is used mainly to display the final result, so that you may apply it after you finish the calculation.

    Code:
    result=0;
    result+= Number(assetCost[rowIndex-1]);
    result=result.toFixed(2);

  4. #4
    Join Date
    Mar 2012
    Posts
    41
    ty very much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles