Sunday 15 May 2011

Round variable in Javascript Google Spreadsheet -


I am interrogating a Google spreadsheet and the number I am getting is blowing some load which I I am doing more in and below.

My question:

  function queryValue3 (met1, met2, met3) {var QUERY3 = new google.visualization.Query ('https://spreadsheets.google.com ? / Spreadsheet / tq range = B7: B9 & amp; key = my_key & gid = 10 '); Query3.send {response (response.isError ()} {warnings (error in 'QUERY3:' + response.getMessage () + '' + response.getDetailedMessage ()); Return;} on data3 = response On M3 = data3.getValue (1, 0); M3 = data3.getValue (2, 0);   

The number I am pulling for M2 is apparently 25.3333333333333323 and the function is blowing me up later. Until my number (in this case I want 10th) function works fine 10th Or to make the 100th goal. Using custom rounds (1 decimal) and it looks correct in the sheet but the query is catching the raw number? In most cases my number is complete and I want that there are no decimal in those examples. Can the variable M1, M2, and M3?

thanks for this matter ...

n.toFixed (2);

You can use it to determine the number of numbers after the decimal Yes

Example:

  foo = 25.3333333333; Foo = + foo.to Fixed (2); / / Plus it makes a number-type again, as it converts to a fixed string. Console.log (foo); // 25.33   

Edit: Approximate side effect is the decimal spherical form:

  foo = 25.127; Foo = + foo.to Fixed (2); Console.log (foo); // 25.13   

The entire number has been omitted only one:

  foo = 23; Foo = + foo.to Fixed (2); Console.log (foo); // 23    

No comments:

Post a Comment