T222's Forum Posts

  • 2 posts
  • "$" & round(Cash * 100) / 100 & (Cash % 1 > 0 ? "." & round((Cash % 1) * 100) : ".00")

    You try "$" & round(Cash * 100) / 100 & (Cash % 1 > 0 ? "." & round((Cash % 1) * 100) : ".00")

    I'm a noob, so I can't guarantee it's correct.

    Thank you. A variation to this worked well: The math made some sense to me /shrug.

    Working Solution:

    "$" & floor(Cash) & "." & right("00" & floor(Cash * 100) % 100, 2)

    Also thank you oosyrag - your answer was tricky for me to figure out for my noobiness, IM learning a lot but 1 week in this broke my lil old brain. I plan to come back and see if it makes more sense to me later and hopefully cool for someone else wanting the same answer =D

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • My first post, and I'm new to both coding and makings games.

    I want to have 2 decimal places with my currency variable.

    Scenario: I've built a little clicker app, which uses currency, and I have picked Dollars as the currency of choice.

    A lot of my products are worth less than a whole Dollar and would break what I'm doing to use whole dollars, which means I need to use cents to 2 decimal places.

    The issue I came across is that when money earnt as a single integer, eg $7.80, it displays as $7.9 - some people are thinking this is 9cents but also, it just does feel nice. or if it is $7.00, this shows as "$7". How do I force 2 decimal places at all times?

    Im rounding to 2 decimal places on all transactions currently.

    Here is what I have to try force the decimal places when the text doesnt have one or both decimal places visible:

    "$" & (round(Cash * 100) / 100) & (Cash % 1 = 0 ? ".00" : "")

    The forum hasnt been great for searching, or I dont know how to use it. Tutorial doesnt jump out with anything helpful.

    Any skilled peeps out there with cool solutions for this?

    -T2

  • 2 posts