[Question] Numberformatting

Exportforce

  • *
  • Posts: 90
Hello,

already thanks for the help :)
My Testgame is coming along way better and faster than expected, but I am running into a problem and that is number formatting.

1. Problem
With already harmless multiplication and division I end up with wrong rounded numbers, so I use  floor/ceil... so far so bad.
How can I force the number to round to 2 decimals after the comma ?

2. Problem
How can I alter a number into scientific notation ?

yoplalala

  • *
  • Posts: 1528
1.  I think you have to multiply by 100 your numbers, do your calculation, round them, and then divide them
2. what do you mean ? You want scientific notation to print it /trace it  or something else?

Exportforce

  • *
  • Posts: 90
1. Okay, gonna try that...

2. I want to make long numbers short, for example: 1000000000 to 10^9
So it's easier to read.

Exportforce

  • *
  • Posts: 90
Hello,

I run into a serious problem.
As the numbers getting higher in my game, they suddenly go into negatives.
This seems to be, because Stencyl uses a too small numberholder (integer?).
Is there a way to use real huge numbers like 1.000.000.000.000.000 and more ?

jalany

  • Posts: 9
I may be wrong...

I'm pretty sure I saw a previous post that recommended storing numbers in groups of 100's as attributes and based on the attribute giving them the scientific notation.
Eg. 1,000,000,000
If *number* > 1,000,000,000
divide *number*/1,000,000,000
and draw/save *result from above* and *^9*

Does that make sense? Granted it would be a bit more in depth but should work.

Exportforce

  • *
  • Posts: 90
Well, that would be serious work... also very inaccurate...
I would need to recalculate that every second on all stuff that uses any form of currency...

Exportforce

  • *
  • Posts: 90
Hi,

sorry for doubleposting, but I am really desperately looking for a way to format numbers and allow big numbers.
Would appreciate help :)

rob1221

  • *
  • Posts: 9424
To format large numbers you need to convert to text, not an integer (so avoid the round block).  Then modify the text depending on how you want to display your numbers.

Exportforce

  • *
  • Posts: 90
So if I use TEXT and have numbers as large as like 100  numbers, Stencyl can work (math) with them without  problems ?

rob1221

  • *
  • Posts: 9424
Converting to text is only for displaying the numbers in a way that looks better.  The standard math blocks are still used.

Exportforce

  • *
  • Posts: 90
Just tried around a bit and couldn't find any way to work with text as number...
But if it is only int and I go higher than INT works, the number is already "destroyed" as it is higher than INT allows.

edit: I tried to show the number inside a "anything as text" but as thought, the number still breaks and gets into negative

« Last Edit: July 15, 2015, 10:28:32 am by Exportforce »

rob1221

  • *
  • Posts: 9424
Yes, so you should never convert to int anywhere in your game.  Going from float to string (text) should not cause a loss in precision, so you must be converting to int somewhere.

Exportforce

  • *
  • Posts: 90
Yes, so you should never convert to int anywhere in your game.  Going from float to string (text) should not cause a loss in precision, so you must be converting to int somewhere.
We do not have the power to choose a format... at least not that I know of... I can only choose "Number" as an attribute format and that is initially an integer, I would not know how I could change that.

rob1221

  • *
  • Posts: 9424
Numbers in Stencyl are Float, not Int, but there are blocks (like the round block) that will convert Float to Int.

Exportforce

  • *
  • Posts: 90
Numbers in Stencyl are Float, not Int, but there are blocks (like the round block) that will convert Float to Int.
Ah okay, that is definitly an info that should be in the editor, didn't even know that. All I got (from other sources) that stencyl only uses INT.  Okay, then I will takeout all round functions and try to find another way for that. BIG THANKS!

edit: But how can I trim those large lengths after the comma ? Often I get something like 12.1999999999999999999999999 and that is a bit weird. As I can't round anymore, how should I get rid of that or at least shorten it to 12.19 ?

« Last Edit: July 15, 2015, 11:02:54 am by Exportforce »