Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

strip decimal points from variable

ok i know this is probably really easy but I am floundering.. I have a series of variables that have a decimal point and a few zeros. How do I strip the variable so it goes from 1.000 to 1 ? Dont think this is that important but the numbers are generated from an xml file that I am grabbing with jquery like ...

var quantity = $("QTY",this).text(); 

Thanks in advance for any help!

like image 816
Zac Avatar asked Apr 11 '11 23:04

Zac


People also ask

How do you remove points from decimals?

Step 1: Write down the decimal divided by 1. Step 2: Multiply both top and bottom by 10 for every number after the decimal point. (For example, if there are two numbers after the decimal point, then use 100, if there are three then use 1000, etc.) Step 3: Simplify (or reduce) the Rational number.

How do you remove decimals from data labels?

Right click on one of the decimal value on the graph and go to format y/x axis and under number tab you have an option to make the decimal places to 0.

How do you remove a decimal point in Visual Basic?

Use the ROUND function (or whichever equivalent function is available in VBA). I have variable to integer so it removes it but it rounds it.


2 Answers

Simply...

Math.round(quantity); 

...assuming you want to round 1.7 to 2. If not, use Math.floor for 1.7 to 1.

like image 59
mVChr Avatar answered Oct 12 '22 12:10

mVChr


use parseInt();

parseInt("1.25");//returns 1 parseInt("1.85");//returns 1 parseInt(1.25);//returns 1 parseInt(1.85);//returns 1 
like image 32
danniel Avatar answered Oct 12 '22 12:10

danniel