#how do I put commas in numbers
1 messages · Page 1 of 1 (latest)
Wdym put commas in numbers? Like a string?
Ye
use a float
What do I use the float for?
its a number but it has decimal
I’m trying to make it have commas though and make it into a string
im not good at yapping how it exactly works so im gonna just pst a pic
Alr
ehh to lazy to remake it
im just gonna show the old one which still works but could be more compact
dere
@haughty furnace
@fathom bronze @grave tundra @haughty furnace @opaque spindle @naive gale
The easiest (and best) way to do this dynamically is to convert the number to a string, and then create a loop from 0 to String Length / 3, and inserting a , at Index * 3, except for index 0
The easiest way to "Insert" a string into another string at a specific index is:
Split the string into 2 strings using 2 String Substring chips, where the first half is Index 0, Length [InsertIndex], and the second one is Index [InsertIndex], Length 512. Then, concat these strings back together with String Concat where the seperator is ,
but thats not a constant string
Yeah, hence the loop, dynamically inserting commas into the string as fit
i know
If u know them don’t help
Hmm... this is a little more complicated than i thought
my current method is working but only when the number of digits is a multiple of 3 (0, 3, 6, 9)
oh, found another problem too lol
same
We need like string step chip
fixed
Just had to add String Length % 3 to the index
@fathom bronze @grave tundra @haughty furnace @opaque spindle @naive gale
Takes any input INTEGER, adds commas as required
This method would work with a string, but you need to remove the decimals first and then add them back after (since you dont give commas to decimals)
The easiest way to just get the number is by using Floor To Int
The easiest way to get just the decimals is by using Modulo and modulo'ing the number by 1, then converting to string and removing the first 2 characters (0.) by using String Substring with index 2 and length 512, then you just concat the result with the decimals, eg. 1050.0555 turns into 1,050.0555
still not constant
wtf do you mean "Not constant"
numbers aren't constant, numbers change
This converts any number into a string with commas
dont u have to excecute the list for etc.?
and? every single chip in the game that uses this value needs an execution too, eg. Text Set Text, Button Set Text, Log String, Print To Text Screen, Add Tag, Objective Marker Set Label
The only thing that can read this value without an execution is the makerpen
Executions aren't bad
stop being scared of executions
I was too at one point and thats why my older circuits suck ass
Can’t you use a mod chip?
huh?
Modulo, I didn’t see you use it later mb