View Issue Details

IDProjectCategoryView StatusLast Update
0002935JEDI VCL00 JVCL Componentspublic2006-06-08 02:28
ReporterglchapmanAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionwon't fix 
Product Version3.00 
Target VersionFixed in Version 
Summary0002935: StrToFloatDef does not allow for exponent
DescriptionThe StrToFloatDef routine in JvJCLUtils begins by scanning the input string and removing invalid chars. Unfortunately, it does not include 'e' and 'E' in its valid chars, so these get removed, leading to incorrect results. I guess this scanning loop is intended to get rid of ThousandsSeparators, but it appears not to have been thought out completely. The routine parses '5xyz 8 &^2' as 582, which to me is surprising. Is the routine guaranteed to be only used in places where it is getting well-formed input?

Also, the routine allows '-' to be a correct number, which evaluates to 0. To me this seems wrong, but perhaps other stuff depends on it. It also seems inconsistent to allow '-' but not '+' (with D5 anyway, TextToFloat rejects '+'; I assume the same happens for later versions).
TagsNo tags attached.

Activities

outchy

2005-05-12 10:17

administrator   ~0007142

This function was created to prevent some TextToFloat bug; '+' and '-' should be considered as 0.
This function delete all extra characters, that's why '5xyz 8 &^2' is understood as 582.
Rejecting 'e' and 'E' is a bug, I fixed only this feature in the CVS.

glchapman

2005-05-14 08:00

reporter   ~0007155

I think it is unfortunate that this function has the same name a standard Delphi function (post-D5) which behaves differently. I only have D5, but I'd be very surprised if the standard StrToFloatDef function, given the input '5xyz 8 &^2', returned something other than the Default argument.

I think at least some review of the uses of this function in JVCL is in order: were any of the uses written with the expectation that the function worked like the standard Delphi function?

obones

2006-03-30 08:02

administrator   ~0008769

What to do here?

outchy

2006-03-31 11:45

administrator   ~0008809

This function should be kept as it presently is. Some users may rely on its light-restrictive behavior.

obones

2006-06-08 02:28

administrator   ~0009428

For backward compatibility reasons, this won't be fixed. However some warning text has been put in JvJCLUtils to inform people about the quirk.

Issue History

Date Modified Username Field Change
2005-05-07 19:56 glchapman New Issue
2005-05-12 10:17 outchy Note Added: 0007142
2005-05-12 11:56 outchy Status new => feedback
2005-05-14 08:00 glchapman Note Added: 0007155
2006-03-30 08:02 obones Note Added: 0008769
2006-03-31 11:45 outchy Note Added: 0008809
2006-06-08 02:28 obones Status feedback => resolved
2006-06-08 02:28 obones Resolution open => won't fix
2006-06-08 02:28 obones Assigned To => obones
2006-06-08 02:28 obones Note Added: 0009428