Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add number->string function to lisp #561

Merged
merged 3 commits into from
Dec 19, 2023
Merged

Add number->string function to lisp #561

merged 3 commits into from
Dec 19, 2023

Conversation

vinc
Copy link
Owner

@vinc vinc commented Dec 18, 2023

Add a function in lisp to convert a number to a string, with an optional radix argument: (number->string number radix)

@vinc
Copy link
Owner Author

vinc commented Dec 18, 2023

~
> lisp
MOROS Lisp v0.6.0

> (num->str 0xFFFF 16) # Hexadecimal
"FFFF"

> (num->str 0xFFFF 10) # Decimal
"65535"

> (num->str 0xFFFF 2) # Binary
"1111111111111111"

> (num->str 0xFFFF 1) # Error
Error: Expected radix in the range 2..37

> (num->str 0xFFFF) # Decimal by default
"65535"

> (num->str 256 16)
"100"

> (num->str 256 2)
"100000000"

@vinc vinc marked this pull request as ready for review December 19, 2023 21:51
@vinc vinc merged commit 82bc08e into trunk Dec 19, 2023
1 check passed
@vinc vinc deleted the feature/lisp-number-string branch December 19, 2023 21:51
@vinc vinc mentioned this pull request Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant