#how do I put commas in numbers

1 messages · Page 1 of 1 (latest)

haughty furnace
#

What’s the best way to put commas in numbers? For example: 196483 = 196,483

naive gale
haughty furnace
#

Ye

opaque spindle
#

use a float

haughty furnace
#

What do I use the float for?

opaque spindle
#

its a number but it has decimal

haughty furnace
#

I’m trying to make it have commas though and make it into a string

grave tundra
#

Just gon show a pic

#

Gettin on in about 10 mins

grave tundra
#

im not good at yapping how it exactly works so im gonna just pst a pic

haughty furnace
#

Alr

grave tundra
#

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
#

ew that’s bad

#

don’t do that

#

i’ll make something one sec

plucky forge
#

@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 ,

grave tundra
#

but thats not a constant string

plucky forge
grave tundra
fathom bronze
plucky forge
#

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

fathom bronze
#

We need like string step chip

plucky forge
#

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

grave tundra
#

still not constant

plucky forge
#

numbers aren't constant, numbers change

#

This converts any number into a string with commas

grave tundra
#

dont u have to excecute the list for etc.?

plucky forge
#

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

plucky forge
naive gale