how to remove decimal from the string field in the server side script

RudhraKAM
Tera Guru

I have this code in the server side , it is giving the result as 44.0 I want only 44 

 current.variables.sds_price = parseInt(current.cmdb_ci.market_value)/1024;

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Please check sample examples from below link , give a try . let me know if it's still not working. 

 

https://stackoverflow.com/questions/7641818/how-can-i-remove-the-decimal-part-from-javascript-number

View solution in original post

12 REPLIES 12

Hi,

Yes, I read your post and all that. You didn't have to repeat yourself.

My script takes that integer value and strips off the decimal and any digits thereafter (as I've said above) and then places that final value in your variable. No decimal should be there.

Anyways, it seems you've found a correct answer, so that's good. My point is, my script works as I tested it as well on my end.

Take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Harsh Vardhan
Giga Patron

Please check sample examples from below link , give a try . let me know if it's still not working. 

 

https://stackoverflow.com/questions/7641818/how-can-i-remove-the-decimal-part-from-javascript-number

Thanks Harsh , tried all but none of them seems working 

Cris P
Tera Guru

Hi there,

 

Could you try:

var floatNum = parseInt(current.cmdb_ci.market_value)/1024;
var intNum = Math.round(floatNum);

current.variables.sds_price = intNum;

tried this too no luck 😞