Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Limiting the digits calculated after 0. ?

Been working on a little calculator project, but the numbers it outputs look kinda messy because Codea calculates so many digits. For example: 1.28547467473725683 As opposed to: 1.28

Is there any way to fix this??

Comments

  • dave1707dave1707 Mod
    Posts: 8,671

    @DJMoffinz Use the string.format() function. There are a lot of options to it, so do a google search or search the forum for examples. To limit the above large number to the smaller one, it would be something like

    function setup()  
        print(string.format("%.2f",1.28547467473725683))     
    end
    

    which would print 1.29 rounded up.

  • Posts: 15

    Thanks for your help!

Sign In or Register to comment.