Displaying Real Attribute

Hi,
Anyone know how to show a real attribute to 2 decimal points only using display text i.e 00.00?. Its displaying really long numbers and I need to keep the size manageable.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    prec(game.score,2)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @tatiang said:
    prec(game.score,2)

    I could be wrong here (correct me if I am) but I thought the use of 'prec' is no longer recommended as it's less efficient than something like roundTo(game.score,2) because 'precision' first needs to convert the attribute it is rounding to text, perform the operation, then convert it back to a number, whereas round/roundTo performs its operation directly on the number. Ultimately it's probably not a big deal, but worth knowing if your game is doing a lot of rounding.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    No, you're probably right @Socks. I don't do a ton of rounding so I just checked the Cookbook and went with that.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    edited October 2017

    @tatiang said:
    No, you're probably right @Socks. I don't do a ton of rounding so I just checked the Cookbook and went with that.

    Ah ! The Cookbook, last updated in the late 1800s. :)

Sign In or Register to comment.