parseInt() value help



  • Hey guys,
    I'm using parsInt() to convert text from a label into an integer. Seems to work properly EXCEPT when I add a 0 in front of 8 or 9.

    01 = 1
    05 = 5
    08 = 0
    09 = 0
    90 = 90
    33333 = 33333
    Here's a simplified example:

    HiseSnippet 947.3ocsV0raaiCDlxwLn1sdQKPuWgbot.oFxo+s.EEqarcJL1FGg3jhdqkVh1lanHEnn5Vih9hzS6ix9xr222ftCEksjaTBZLvpSdl4al4aFNbn8Ux.ZRhTgbZb1xXJx4N3IKE5E8WPXBznAFEwDUB0USSznCWFSRRngHGmcdiAgSi5nru+82NjvIh.ZgJD5cRV.8srHltPqeuemw4GQBomwhJg9o8FEHE8kbYJvlcvdnXRvEj4zwDCrZXjytCCYZoZhl.jAvbnLb4jEx+TXw+NVBaJmZD5hl.AxpF0eAiG5upRSPHm59E08N15993iYgr05Kp+6lYvsvix8.mZaRo5aPotWEkNRxCMA3JnmSI5U2Ru6gmDnXw5BKFtca7HglplQf1dYZYwhp8fZ39R.gP2IhbA8HEHr1i1O2yae2m448nW1pYqlPyOQ69IhxkSlR4Z3vQ49J2gh4LAsSfhBUn4DScxz+fFnaa7p.YmDMQoyr2thP9VCvtP3VQm4TceYTrT.Bs2yZdOiW+fOGb89bvd1LUlHTKM5S37ovDT6Yoh.MSJZ+nVM+hArK7YR.SDmpg3aytI7s2SS+rNKlFPPhSjbZmXECxXF7UlrY2jrbe12M6Zxn0.MH+pkcqXfqTLVpom.To4WZ1n4Wa59illMqRalVfRx4P2sJy19903XaQZzTpZent4oz0.gwqMmeu8O27af8DoDPoXjfoOIllKWLgarYq5UV8PqK1xpJpwxZsibWFVgpKeABkOw.+57QCHZh4NUtN.WLUoYlp0Y.8SvBJ6MrF3AzjKzxXnordLC4f0YVake+K6bGwfJ6WviF6e9YtiO+3CGdJ5yEaxF2a4Zgd98nPGlj0Dc1AUJx6dUQ9VX6DY4X5WJl+866YF4.dh85hlNe0NyF6he32+VFjaPZNnTZ9KUUoowtN46yKmq+Ae4bckMq6h8e8oSFNvcz3yF9lMZWeTcMsqKuHDVGKCS4D8l6nMOFka.F72XYnYgmHgoWV9wpavhauJWb2sp4teR5dOrOSGrnZ9VqB9Byu+ey27mAagGNaFrdufr0wG89s8Mua.UNUlpYh4GSzJFLbfGmFMAlzBn.SDBJGRD1olYbyJ6YjMclITQXlv2gubicMxN4F6txHJhDnjeHvt.w7P6sxz.bRj8eLZfO1H61EkslD7C60wCEAu++gf.Sq3w.2q1mC1BedxV3yS2Bed1V3yy2BedwV3yuds9X9qWuNUKirWS.E9CyVn63LTX1RjMQh9O.ZJgeN
    


  • parseInt sometimes does weird things. Use Math.round() instead.





  • @Christoph-Hart thanks for this! Math.round gets the job done, so I'm happy 🙂


Log in to reply
 

9
Online

1.2k
Users

3.9k
Topics

34.1k
Posts