0

Can google app script use external library in google app script that can do float number calculation, like bigdecimal?

when I do

var i =  1.15 - 1.12 
console.log(i); 

then i = 0.029999999999999805

1 Answer 1

1

Just to answer the question if it's possible, the answer is Yes, based on this SO post.

However if you wanted to round it up to 2 decimal places only (or more), you don't have to resort to external library, use Math.round:

function floatNumber(){

    var myInt =  1.15 - 1.12 ;
       myInt = Math.round(myInt * 100) / 100;
       Logger.log(myInt);
       //output 0.03
       //if you want 3 decimal places use /1000, and so on.
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.