Page 1 of 1

strstr() doesnt recognise scientific notations

Posted: Mon May 30, 2022 7:13 pm
by Bugala
Not sure this is necessarily a bug, but worth a notice anyway.

Code: Select all

string = 2.3e-5

newstring = StrStr(string, 2)

DebugPrint(newstring)
As you can see, when using StrStr() Hollywood fails to recognize scientific notation e format, and result of this one is strangely "2.3e" which makes no sense.

Since the idea with StrStr() to my understanding is specifically to change a number into a string form, it would make sense it would take into notion the scientific notation format e when doing this "up to x decimals" change since the result is clearly wrong.

Re: strstr() doesnt recognise scientific notations

Posted: Mon May 30, 2022 8:56 pm
by plouf
problem is as it seems the decimal points, it filter it plain after dot, where is this complex scenario fails

moer test

Code: Select all

string$ = "2.3e-5"

number = Val(string$)

DebugPrint(number)
DebugPrint(GetType(number)=#NUMBER)

newstring$ = StrStr(number,10)
DebugPrint(newstring$)
DebugPrint(GetType(newstring$)=#STRING)

formatstring$ = FormatStr("%.2e",number)
DebugPrint(formatstring$)

formatstring$ = FormatStr("%.6e",number)
DebugPrint(formatstring$)

Re: strstr() doesnt recognise scientific notations

Posted: Sun Jun 05, 2022 9:39 pm
by airsoftsoftwair
True, this looks like a bug. Will be fixed.

Re: strstr() doesnt recognise scientific notations

Posted: Fri Jun 17, 2022 9:16 pm
by airsoftsoftwair

Code: Select all

- Fix: The digits argument in StrStr() wasn't handled correctly in case the string used the exponential notation