[BASIC] STR$() odd question

By sergarbes

Expert (116)

Аватар пользователя sergarbes

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

By Briqunullus

Paladin (775)

Аватар пользователя Briqunullus

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

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

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