Opened 5 years ago

Closed 4 years ago

#17672 closed enhancement (wontfix)

replace current IsNumber() which should not be used in new code

Reported by: raananc Owned by:
Priority: normal Milestone:
Component: base Version: dev-latest
Keywords: IsNumber Cc:
Blocked By: Blocking:
Patch: yes


From the forum discussion it looks like the reason for not recommending IsNumber() is the inherent inefficiency linked to its use. However, the lack of a replacement makes testing for number cumbersome.

The enclosed patchs reinstate IsNumber() in two variants which use ToLong() as a tester:

bool IsNumber();
bool IsNumber (long* val);

The first is for those who need to know if a string is numeric without requiring the numerical value.

The second provides the numerical value as well.

Attachments (1)

stringcpp.diff download (877 bytes) - added by raananc 5 years ago.

Download all attachments as: .zip

Change History (6)

Changed 5 years ago by raananc

comment:1 Changed 5 years ago by raananc

Missed attaching the second file, which simply adds the line

bool IsNumber(long *v) const;


bool IsNumber() const;

Last edited 5 years ago by raananc (previous) (diff)

comment:2 Changed 5 years ago by raananc

  • Type changed from defect to enhancement

comment:3 Changed 5 years ago by raananc

  • Patch set

comment:4 Changed 5 years ago by raananc

  • Version changed from 3.0.2 to dev-latest

comment:5 Changed 4 years ago by vadz

  • Resolution set to wontfix
  • Status changed from new to closed

Sorry, I don't know anything about the forum discussion and I don't understand why should this function be changed and especially the reason for adding a new overload which is exactly the same as (more clearly named) ToLong().

The first change also changes the behaviour of the method (think of the different special cases: empty string, very long string which would result in an overflow with ToLong(), ...), and I'd really like to avoid doing this for this legacy stuff and without any good reason.

Note: See TracTickets for help on using tickets.