Scientific notation fraction

0 favourites
  • 3 posts
From the Asset Store
An educational game for doing fractions. An easy to use template for developers to build larger games
  • Good evening, everyone.

    (Sorry for being a math noob)

    I am creating some incremental mechanics and I noticed something about working with large numbers;

    Incrementing the number by 10 will eventually call for a scientific notation.

    At some point, the number X gets to Xe+21 which is alright, but then it turns out to X.9999999999999995e+25 and I wanted to know ...

    How do I get rid of this fraction?

    | Global number Variable‎ = 0 + System: On start of layout -> System: Set Variable to 4 -> Text: Set text to Variable + Keyboard: On A pressed -> System: Set Variable to Variable×10 -> Text: Set text to Variable

  • This may come down to float rounding error, which is a byproduct of how computers work. with floats. I'm not sure if rounding works with scientific notation but you can try "set text to round(variable)"

    If that doesn't work you might have to employ some custom logic to extract the fraction, round it and put it back together, something like that (off the top of my head, I didn't test this)

    set text to round(int(tokenat(str(variable),0,"e"))) & "e" & tokenat(str(variable),1,"e")

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Good evening!

    your workaround with "tokenat" turned out great. I've been testing it so far and in my case, it is exactly what I was looking for. Thank you a ton.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)