Numeric constants and 'D' as an exponent

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Numeric constants and 'D' as an exponent

Dave Nichols
The tonumber function appears to accept a 'D' (or 'd') as the exponent character as well as the documented 'E' (or 'e'). Is this intended?
E.g. tonumber'2d2' returns 200
This is version 5.1.2 but there are no patches related to this up to 5.1.4

--
Regards,

Dave Nichols
Match-IT Limited
Tel: 0845 1300 510
Fax: 0845 1300 610
[hidden email]
http://www.make247.co.uk

Email Disclaimer: The contents of this electronic mail message and any attachments (collectively "this message") are confidential, possibly privileged and intended only for its addressee ("the addressee"). If received in error, please delete immediately without disclosing its contents to anyone. Neither the sender nor its management or employees will in any way be responsible for any advice, opinion, conclusion or other information contained in this message or arising from it's disclosure.

Reply | Threaded
Open this post in threaded view
|

Re: Numeric constants and 'D' as an exponent

Ken Smith-2
5.1.3 doesn't appear to accept D or d.

Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> =tonumber('2d2')
nil
> =tonumber('2D2')
nil
> =tonumber('2e2')
200
> =tonumber('2E2')
200


On Mon, Nov 3, 2008 at 11:30 AM, Dave Nichols <[hidden email]> wrote:
The tonumber function appears to accept a 'D' (or 'd') as the exponent character as well as the documented 'E' (or 'e'). Is this intended?
E.g. tonumber'2d2' returns 200
This is version 5.1.2 but there are no patches related to this up to 5.1.4

--
Regards,

Dave Nichols
Match-IT Limited
Tel: 0845 1300 510
Fax: 0845 1300 610
mailto:[hidden email]
http://www.make247.co.uk

Email Disclaimer: The contents of this electronic mail message and any attachments (collectively "this message") are confidential, possibly privileged and intended only for its addressee ("the addressee"). If received in error, please delete immediately without disclosing its contents to anyone. Neither the sender nor its management or employees will in any way be responsible for any advice, opinion, conclusion or other information contained in this message or arising from it's disclosure.

Reply | Threaded
Open this post in threaded view
|

Re: Numeric constants and 'D' as an exponent

Peter Cawley
Lua uses the C library function strtod to convert strings to numbers.
Some CRT implementations only permit 'e' and 'E' to be used to begin
the exponent (i.e. as described on
http://www.cplusplus.com/reference/clibrary/cstdlib/strtod.html ),
while others permit 'e', 'E', 'd' or 'D' to be used (i.e. the MSVC CRT
described on http://msdn.microsoft.com/en-us/library/kxsfc1ab(VS.71).aspx
)

2008/11/3 Ken Smith <[hidden email]>:
> 5.1.3 doesn't appear to accept D or d.
>
> Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
>> =tonumber('2d2')
> nil
>> =tonumber('2D2')
> nil
>> =tonumber('2e2')
> 200
>> =tonumber('2E2')
> 200
>
>
> On Mon, Nov 3, 2008 at 11:30 AM, Dave Nichols <[hidden email]>
> wrote:
>>
>> The tonumber function appears to accept a 'D' (or 'd') as the exponent
>> character as well as the documented 'E' (or 'e'). Is this intended?
>> E.g. tonumber'2d2' returns 200
>> This is version 5.1.2 but there are no patches related to this up to 5.1.4
>>
>> --
>> Regards,
>>
>> Dave Nichols
>> Match-IT Limited
>> Tel: 0845 1300 510
>> Fax: 0845 1300 610
>> [hidden email]
>> http://www.make247.co.uk
>>
>> Email Disclaimer: The contents of this electronic mail message and any
>> attachments (collectively "this message") are confidential, possibly
>> privileged and intended only for its addressee ("the addressee"). If
>> received in error, please delete immediately without disclosing its contents
>> to anyone. Neither the sender nor its management or employees will in any
>> way be responsible for any advice, opinion, conclusion or other information
>> contained in this message or arising from it's disclosure.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Numeric constants and 'D' as an exponent

Dave Nichols
I've upgraded to 5.1.4 and its the same and its windoze, so your analysis must be correct. It took me by surprise. I was using tonumber() to distinguish strings from numbers (being lazy) and this string '05D34306' converted to a number (which displayed as 1.#INF). My script then collapsed.

Peter Cawley wrote:
Lua uses the C library function strtod to convert strings to numbers.
Some CRT implementations only permit 'e' and 'E' to be used to begin
the exponent (i.e. as described on
http://www.cplusplus.com/reference/clibrary/cstdlib/strtod.html ),
while others permit 'e', 'E', 'd' or 'D' to be used (i.e. the MSVC CRT
described on http://msdn.microsoft.com/en-us/library/kxsfc1ab(VS.71).aspx
)

2008/11/3 Ken Smith <[hidden email]>:
5.1.3 doesn't appear to accept D or d.

Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
=tonumber('2d2')
nil
=tonumber('2D2')
nil
=tonumber('2e2')
200
=tonumber('2E2')
200


On Mon, Nov 3, 2008 at 11:30 AM, Dave Nichols <[hidden email]>
wrote:
The tonumber function appears to accept a 'D' (or 'd') as the exponent
character as well as the documented 'E' (or 'e'). Is this intended?
E.g. tonumber'2d2' returns 200
This is version 5.1.2 but there are no patches related to this up to 5.1.4

--
Regards,

Dave Nichols
Match-IT Limited
Tel: 0845 1300 510
Fax: 0845 1300 610
[hidden email]
http://www.make247.co.uk

Email Disclaimer: The contents of this electronic mail message and any
attachments (collectively "this message") are confidential, possibly
privileged and intended only for its addressee ("the addressee"). If
received in error, please delete immediately without disclosing its contents
to anyone. Neither the sender nor its management or employees will in any
way be responsible for any advice, opinion, conclusion or other information
contained in this message or arising from it's disclosure.



--
Regards,

Dave Nichols
Match-IT Limited
Tel: 0845 1300 510
Fax: 0845 1300 610
[hidden email]
http://www.make247.co.uk

Email Disclaimer: The contents of this electronic mail message and any attachments (collectively "this message") are confidential, possibly privileged and intended only for its addressee ("the addressee"). If received in error, please delete immediately without disclosing its contents to anyone. Neither the sender nor its management or employees will in any way be responsible for any advice, opinion, conclusion or other information contained in this message or arising from it's disclosure.

Reply | Threaded
Open this post in threaded view
|

Re: Numeric constants and 'D' as an exponent

Linker
> =tonumber"05D34306"
1.#INF

It's a float-overflow.
On Tue, Nov 4, 2008 at 18:35, Dave Nichols <[hidden email]> wrote:
I've upgraded to 5.1.4 and its the same and its windoze, so your analysis must be correct. It took me by surprise. I was using tonumber() to distinguish strings from numbers (being lazy) and this string '05D34306' converted to a number (which displayed as 1.#INF). My script then collapsed.


Peter Cawley wrote:
Lua uses the C library function strtod to convert strings to numbers.
Some CRT implementations only permit 'e' and 'E' to be used to begin
the exponent (i.e. as described on
http://www.cplusplus.com/reference/clibrary/cstdlib/strtod.html ),
while others permit 'e', 'E', 'd' or 'D' to be used (i.e. the MSVC CRT
described on http://msdn.microsoft.com/en-us/library/kxsfc1ab(VS.71).aspx
)

2008/11/3 Ken Smith <[hidden email]>:
 
5.1.3 doesn't appear to accept D or d.

Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
   
=tonumber('2d2')
     
nil
   
=tonumber('2D2')
     
nil
   
=tonumber('2e2')
     
200
   
=tonumber('2E2')
     
200


On Mon, Nov 3, 2008 at 11:30 AM, Dave Nichols <[hidden email]>
wrote:
   
The tonumber function appears to accept a 'D' (or 'd') as the exponent
character as well as the documented 'E' (or 'e'). Is this intended?
E.g. tonumber'2d2' returns 200
This is version 5.1.2 but there are no patches related to this up to 5.1.4

--
Regards,

Dave Nichols
Match-IT Limited
Tel: 0845 1300 510
Fax: 0845 1300 610
mailto:[hidden email]
http://www.make247.co.uk

Email Disclaimer: The contents of this electronic mail message and any
attachments (collectively "this message") are confidential, possibly
privileged and intended only for its addressee ("the addressee"). If
received in error, please delete immediately without disclosing its contents
to anyone. Neither the sender nor its management or employees will in any
way be responsible for any advice, opinion, conclusion or other information
contained in this message or arising from it's disclosure.
     
   


 

--
Regards,

Dave Nichols
Match-IT Limited
Tel: 0845 1300 510
Fax: 0845 1300 610
mailto:[hidden email]
http://www.make247.co.uk

Email Disclaimer: The contents of this electronic mail message and any attachments (collectively "this message") are confidential, possibly privileged and intended only for its addressee ("the addressee"). If received in error, please delete immediately without disclosing its contents to anyone. Neither the sender nor its management or employees will in any way be responsible for any advice, opinion, conclusion or other information contained in this message or arising from it's disclosure.



--
Regards,
Linker M Lin
[hidden email]