#How to Isolate the end of a string

3 messages · Page 1 of 1 (latest)

odd rover
#

I have these strings that represent a fp number in hex and im trying to isolate the end and cast it into an int.
These are my strings.

-0x1.6e7ceep+14
0x1.01b2b2p-23

for example, I want my return value to be 14 and -23 respectively. How could I go about doing this?

twin shardBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For more information use !howto ask.

cinder granite
#

You could either parse the string or loop it backwards, adding to an int the according value until you find a non-digit. If it's -, set the number to negative itself, ignoring the rest.