Reversing an Integer's Digits
|
09-20-2022, 06:01 AM
(This post was last modified: 09-20-2022 06:02 AM by Didier Lachieze.)
Post: #2
|
|||
|
|||
RE: Reversing an Integer's Digits
Thanks for that. The addition to reverse a number is a nice trick if you have an easy way to get access to the individual digits.
Otherwise on the Prime you can also use this one liner that you can define as a user function to reverse the number N: EXPR(CHAR(REVERSE(ASC(STRING(N))))) It works with integers and also with positive decimal numbers, for example for 67.28 it returns 82.76 To reverse both positive and negative numbers you need: SIGN(N)*EXPR(CHAR(REVERSE(ASC(STRING(ABS(N)))))) |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Reversing an Integer's Digits - Eddie W. Shore - 09-20-2022, 05:18 AM
RE: Reversing an Integer's Digits - Didier Lachieze - 09-20-2022 06:01 AM
|
User(s) browsing this thread: 1 Guest(s)