Tonumber can't represent repeated zeroes

Not sure if this is intentional or not but tonumber can’t output any repeated zeroes from either rep or strings.

Is this by default if so is there any workarounds around it?

image

tonumber(n) doesn’t include non-significant figures because 00000000 is still equivalent to 0 (this is true for tonumber("0n"), which gives n).

May I ask why you need this specific behavior? Is it for displaying purposes?

1 Like

If you want to show something to a fixed number of digits (including preceding zeros) you can try do

string.format("%.5d", number)

which prints out number with 5 digits total.

same thing as print(00000000), it would still print 0. because lua evaluates 0000000 as 0 because it’s equal.

“00000000” would be a string…

A=2112
B=“00000000”
C=(A+B)

print(C)

https://xyproblem.info/

2 Likes

Basically yeah and learning more

‭‭‭‭‭‭‭‭Learning more about what

you’re a cool person i like you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.