Closed noahyor closed 7 months ago
how would this work though? can you provide example syntax, thanks
-> b
would convert to binary?
or
-b>
?
Could work by repeatedly using left bit shift 1 modulo 2. I think you shouldn't allow it to convert non-integer values.
its already spec to use 0b... for binary, and 0x... for hex, i can encode constants that way, but for outputting ones, i honestly don't have a clue, i could change the base in the output
you could write 0d3 -b>
and it would output 0b11
, for example
I think i might like to try to implement this on a local branch.
I see the problem with printing the converted string now. I think I might be able to do it with some major refactoring. As a side note, I fixed the crash that happened when an invalid decimal format string was used. In the case of an invalid string, it reverts to the default for the remainder of that session.
you could write
0d3 -b>
and it would output0b11
, for example
chatcalc does not support spaces in expressions i can always make my own decimal formatter and allow it to have custom bases
smth like rust:
.2
for (1.234 -> 1.23)
,.2
for (1024.32 -> 1,024.32)
04,.2
for (4.1 -> 0004.10)
.<2
for (4.133 -> 4.13 or 4.1 -> 4.1)
00.<2
for (1.2 -> 1.2 or 0.2 -> .2)
#01.<2
for (10 -> A or 10.4 -> A.67) (the 01 is inferred and can be omitted)
b.0
for (3 -> 10 or 127 -> 1111111) (the .0 is inferred and can be omitted)
hows that look?
I don't understand that format. Could you please re-explain?
a comma adds commas
a .
then a number specifies the amount of decimals to put in
a 0 then a number says the minimum amount of digits in the int part, ex: 01 is the default so 0.2 becomes 0.2 but if it were 02
then 0.2 would be 00.2, or 00
would have no prefixing int parts at a minimum, meaning .2 is the result
a # makes the number hex, a b makes the number binary
adding a <
between the .
and the int (for the number of decimal places) makes it go up to that, that way 1.2 doesn't map to 1.20 unnessesarily
I like that, thanks for the explanation!
hi so, ok, idk how to say this, but this is difficult, like crazy difficult, I could totally work on this but it would take a week to do and that's time I don't have right now, I can totally add 0b111
constants and 0xFF
constants, but if I'm adding custom base printouts, that's incredibly difficult with my current time. because of this, I'm likely unable to add this feature, I hope you understand.
That is fine. I think I might like to do this on my own time. If I somehow get it to work I can give you the code.
the challenge is getting it to work with floats, not just integers
How would the floats theoretically work?
well in my dev version, constants already exist like 0b11.11
for 3.75
, or 0xFF.FF
for 255.99609375
so like that
I've never really used decimal places in other bases before, but ok.
good luck
thanks.
I think it might be nice to be able to convert to and from binary and/or other bases within this mod without doing tedious manual conversion. Thank you for your work on this mod!