Reply to topic  [ 2 posts ] 
Interpretation of huge numbers cause syntax error 
Author Message
Yorick Guru

Joined: Thu May 10, 2007 12:07 pm
Posts: 62
Post Interpretation of huge numbers cause syntax error

I have seen strange behaviour of the yorick interpreter on one machine.
On a code that already exists and has been proved to work on many platform, they are some numbers writen as 1e999 1e500 they are actually inf numbers. The code use them to test a inf or nan (bad coding it should use ieee_test, anyway, ..).
I saw on one Linux machine that when there are such numbers in the file the interpreter (not the execution, just the include of the file) get completely confused and end up with a syntax error or it kind of "jumps out of a function" and crash.
I would I guessed problem with the execution as inf and NaN interpretation can be very machine dependent, but I was surprise it was at the include level.
I think they are fixing the code without problems, but how this can make sense ?

I do not have details of the machine but I can come up with the details if david is interested to have.


Wed Sep 04, 2013 6:55 am
Yorick Master

Joined: Mon Nov 22, 2004 9:43 am
Posts: 354
Location: Livermore, CA, USA
Post Re: Interpretation of huge numbers cause syntax error
This is not a bug, it's a feature.

Yorick is designed to NEVER produce nor interpret Inf or NaN -- it is supposed to generate SIGFPE instead. It uses the libc strtod function to parse all floating point numbers. The behavior of strtod for non-representable numbers (generally greater than about 1.7e308) is unclear. To the extent strtod behavior is non-standard, yorick will do different things on different platforms. If I could easily do so, I would make non-representable numbers generate a clean syntax error. Maybe I'll write my own replacement for strtod someday to make yorick behave the same on all platforms, but until then, it's just something you have to cope with. Any yorick program containing a numeric constant larger than the largest representable double is an incorrect program. Do not attempt to do that.

The ieee.i library file in Y_SITE/i/ contains yorick functions to identify Inf and NaN patterns, if you need to read binary data from files written by lousy programs that produce them. You can use these functions to replace those hurtful and dangerous patterns with actual numbers that yorick can process without SIGFPE.

Thu Sep 05, 2013 8:33 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.