
1. Re: How to get exact values.
Jump_Over May 23, 2013 3:23 AM (in response to shilpa25)1 person found this helpfulHi,
you need to round this floats (i.e.):
mWidth = Math.round(mWidth*100)/100;
Jarek

2. Re: How to get exact values.
shilpa25 May 25, 2013 2:43 AM (in response to Jump_Over)1 person found this helpfulHi Jarek,
Many Many apologise for the delayed response.
I fall in sick...
Many thanks for your reply..
I have a request to you... if I use Math.round it rounds ups the value...
but, my request is to have the exact digits that is seen in Measurement tools. Wight and Height....
eg. 23.457 in Width.... when using Math.round, i get as 23.5,
I need to get the exact values 23.457...
many thanks jarek..... much appreciated for your help....

3. Re: How to get exact values.
MrTIFF May 25, 2013 5:48 AM (in response to shilpa25)Math.round() always rounds to the nearest whole number (integer). So Jarek's suggestion uses Math.round in a particular way ... he isn't rounding mWidth directly  he is multiplying mWidth by 100, rounding the result to the nearest integer, and then dividing by 100. This gives you exactly 2 decimal places of accuracy. If you want 1 decimal place, use 10 instead of 100. If you want 3 decimal places, use 1000.
A general routine to round a floating point number to a particular number of decimal places is:
// rounding to a give number of decimal places (tomaxxi)
Number.prototype.doRound = function(roundDec){
var roundMulit = Math.pow(10,roundDec);
return Math.round(this*roundMulit)/roundMulit;
};
If you put the above code snippet at the beginning of your script, then in the main part of your script you can just do this:
mWidth = mWidth.doRound( 3 );
, if you want to round to at most 3 decimal places.
Generally, you only want to do this in UI code, because there is a good chance that rounding the number (mWidth in this case) will LOSE precision, not GAIN precision, when you round to a certain number of decimal places. (Explaining exactly why this is true is a longer discussion.)

4. Re: How to get exact values.
shilpa25 May 26, 2013 2:41 AM (in response to MrTIFF)A great help from you, with indeed explanations. I accept the point (Explaining exactly why this is true is a longer discussion.).
Thanks so much, for what have you tuted in this discussion. Much appreciation to you..
Jarek, thanks so much to you also...
thanks stephen0218 ji....
j,
Shil...