cancel
Showing results for 
Search instead for 
Did you mean: 

isnumeric('e') returns 1

Former Member
0 Kudos

Hi

In ASE15.7, the function isnumeric('e') returns 1. Same thing for isnumeric('E').

The Sybase case 11516623 says it is an expected result as 'e' refers to exponent.

If it is expected why it is not indicated in the documentation:

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc36271.1570/html/blocks/bl...

It is very confusing. What do you think?

thanks,

Vincent

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks for all your comments!

That would be nice if the function isnumeric could make the difference between the letter 'e' and the exponent 'e1' or '1e1'.

Ideally a CR should be opened as this problem created a bug in our application (so could create problems with other customers) but I am too tired to "argue" again with the Support.... 😞

former_member188958
Active Contributor
0 Kudos

This is a bug as the documentation states that a result of 1 guarantees that the value is convertible to int, float, money, and decimal datatypes.  I've opened CR 767440. 

Former Member
0 Kudos

Thank you Bret!

Would it be a public CR or it will require to ask the support to get an update on the CR?

former_member188958
Active Contributor
0 Kudos

I did write the CR with a public description, but it isn't showing up yet on the Solved Cases search page.

Former Member
0 Kudos

"e" should refer to the constant IMO.  e (mathematical constant) - Wikipedia, the free encyclopedia

Former Member
0 Kudos

IMO 'e' is first a letter. This letter was used later to refer to the Euler constant by the mathematicians.

If we start using e for the exponent, why not using all the other mathematician symbols such as 'i' to refer to the i used in complex numbers (i2 = -1), or 'g' for the gravitational force (9.80...)...

kevin_sherlock
Contributor
0 Kudos

There are other fringe cases as well.  These characters are considered numeric on their own: (my client charset , and server charset are "iso_1"):

"." -  period

"," - comma

"$" - currency sign

"+" - plus sign

"-" minus sign, or "dash"

"e" and "E" - already mentioned

ascii character 163 - "currency symbol"

ascii character 164 - "currency symbol"

ascii character 165 - "currency symbol"

ascii characters 9 thru 15 - "mostly unprintable characters, but include linefeed, and carriage return"

ascii character 32 - "space"

For your entertainment, run this query on your ASE:

select ''''+char(number)+'''' as "Character"

    , number as "AsciiCode"

    , isnumeric(char(number)) as "IsNumeric?"

from master..spt_values

where type = 'P'

and  number between 1 and 254

and isnumeric(char(number)) = 1

Message was edited by: Kevin Sherlock - eliminated discussion about "long" literals, was reading incorrect doc set

former_member188958
Active Contributor
0 Kudos

Hi Kevin,

Thanks for digging in a bit deeper.  I've added all these examples to the CR.

-bret

former_member182259
Contributor
0 Kudos

.....ooops spoke too quick:

select convert(numeric,'e') returns 0......ala 1.0e0 is the interpretation of 'e'.....weird as 'e' is float notation and convert(float,'e') throws an error.

former_member182090
Active Participant
0 Kudos

I agree it's confusing, because 'e' is not recognized as a numeric expression in its own right. I.e. the following fails:

1> select convert(float,'e')

2> go

Msg 249, Level 16, State 1

Server 'SYB157', Line 1

Syntax error during explicit conversion of VARCHAR value 'e' to a FLOAT field.

If this worked, then it would be logical that isnumeric('e') returns 1.

arthurkirchner
Explorer
0 Kudos

Sadly, this works:

1> select cast ('e' as numeric)

2> go

SQL Server fails with the same query, here it has to be

select cast ('0e0' as numeric)