You must Sign In to post a response.
  • Category: JavaScript

    Float values Substraction gives negative results in javascript

    I try to substract two variable like as

    var a = 3602.72238;
    var b =2597;

    var c = a - b;
    it gives negative the answer c =-1005.72238

    I want to positive answer like 1005.72238
    Whats wrong how rid of minus.

    Plz advice
    Thanks and regards
    brite
  • #769538
    Hi Brite,

    Try the below code,
    var c = parseFloat(a) - parseFloat(b);

    Regards,
    V.M. Damodharan
    "Your talent will be worthless, when you have fear and tension."


  • Sign In to post your comments