[BASIC] STR$() odd question

By sergarbes

Expert (116)

sergarbes's picture

29-03-2022, 17:33

Hi all!

I'm going to ask an odd question about BASIC STR$() function. Why It returns one space character from the left, plus the conversion, having to subtract 1 when you want to LEN() the result of STR$()

Thanks in advance!

Smile Smile Smile

Login or register to post comments

By Briqunullus

Paladin (775)

Briqunullus's picture

29-03-2022, 18:37

I've always thought the space character is reserved for the minus sign when converting negative values.

By Parn

Paladin (854)

Parn's picture

30-03-2022, 02:11

As Briqunullus said. If it's a negative value, then the first character will be a minus (character 45). Otherwise, it will always be a space (character 32).

By sergarbes

Expert (116)

sergarbes's picture

30-03-2022, 09:34

Cool, I didn't thought about it. You are both right. I have just tested it! I am in the process of relearning BASIC for fun and trying to develop a game is the final objective. Thank you for your answers!

Wink Wink Wink