strstr() doesnt recognise scientific notations

Report any Hollywood bugs here
Post Reply
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

strstr() doesnt recognise scientific notations

Post 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.
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: strstr() doesnt recognise scientific notations

Post 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$)
Christos
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: strstr() doesnt recognise scientific notations

Post by airsoftsoftwair »

True, this looks like a bug. Will be fixed.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: strstr() doesnt recognise scientific notations

Post by airsoftsoftwair »

Code: Select all

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