Euphoria Ticket #877: Numbers out of range give silly results

When the Euphoria front end reads a number outside the range of floating point numbers, the result is silly instead of reporting a failure. See the forum topic
? 2e100_000 -- a killer statement.
A simple example is:

?2e309 

This is too large for the floating point range and Euphoria should report an error. Instead it shows a ridiculously small number:
6.180692095e-308

Arthur

Details

Type: Bug Report Severity: Major Category: Front End
Assigned To: SDPringle Status: Fixed Reported Release: 4.05
Fixed in SVN #: View VCS: none Milestone: 4.0.6

1. Comment by jimcbrown Jul 04, 2013

Euphoria first needs to support detecting float point errors internally, before it can do anything with that information (like throw an exception to notify user code).

We can implement it with these functions: http://www.gnu.org/software/libc/manual/html_node/Status-bit-operations.html#Status-bit-operations

In the meantime, it should be pretty easy for someone else to write some define_c_func() wrappers around these functions (which would allow them to be used in Euphoria code today).

None of this settles the question of what the scanner should do when it detects this, however.

2. Comment by SDPringle Jan 20, 2015

Until Euphoria supports exceptions, for operations done by the backend, all we can reasonably do is support this fenv.h interface so that users can check things. But the ticket is about the front-end. Now, the front end can use the same interface and say something like "The number is too big" or "the number is too small".

3. Comment by ArthurCrump Jan 20, 2015

As well as the front end, the value() function has the same problem.

Surely it should be possible to check that the string representation of a number is valid without resorting to exceptions.

Arthur

4. Comment by SDPringle Jan 20, 2015

I tried this statement and the interpreter hangs rather than return such a value. It is simply too big for the scanner's code to process efficiently right now. It seems to me we should set these to inf. Numbers literals like 1e-200_000 should get a value of 0.

Or should value() give you 'GET_FAIL' in the first member?

5. Comment by SDPringle Jan 20, 2015

I am using the HEAD version of 4.0, not 4.0.5. Things have changed since 4.0.5.

6. Comment by SDPringle Jan 24, 2015

See: hg:euphoria/rev/ccd213d907d4

changeset: 6284:ccd213d907d4 branch: 4.0 tag: tip user: Shawn Pringle <shawn.pringle@gmail.com> date: Sat Jan 24 12:12:04 2015 -0300 files: docs/release/4.0.6.txt include/std/get.e source/common.e source/error.e source/msgtext.e source/scanner.e source/scinot.e tests/t_c_overflow_sbni.d/control.err tests/t_c_overflow_sbni.e tests/t_c_overflow_sci1.d/control.err tests/t_c_overflow_sci1.e tests/t_c_overflow_sci2.d/control.err tests/t_c_overflow_sci2.e tests/t_c_overflow_sci3.d/control.err tests/t_c_overflow_sci3.e tests/t_c_overflow_sci4.d/control.err tests/t_c_overflow_sci4.e tests/t_c_overflow_sdnf.d/control.err tests/t_c_overflow_sdnf.e tests/t_c_overflow_sdni.d/control.err tests/t_c_overflow_sdni.e tests/t_c_overflow_shni.d/control.err tests/t_c_overflow_shni.e tests/t_c_overflow_soni.d/control.err tests/t_c_overflow_soni.e tests/t_c_underflow_sci.d/control.err tests/t_c_underflow_sci.e tests/t_c_underflow_sdn.d/control.err tests/t_c_underflow_sdn.e tests/t_get.e tests/t_literals.e description:

  • fixes ticket 877 and ticket 917

7. Comment by SDPringle Jan 25, 2015

See: hg:euphoria/rev/b508630d52bc

changeset: 6290:b508630d52bc branch: 4.0 parent: 6284:ccd213d907d4 user: Shawn Pringle <shawn.pringle@gmail.com> date: Sun Jan 25 08:28:43 2015 -0300 files: source/fenv.e description:

  • adds a necessary file used for fixing ticket 877 and 917

8. Comment by SDPringle Jan 25, 2015

I have added tests and these tests show that the literals get assigned to inf when the literal is bigger than the limit and zero when less than the smallest sub-normal. Wine or Windows doesn't support the status bit. So, although the interpreter doesn't crash and the numbers are correct as they can be, there is no error reporting on Wine when the literals are out of range. Please try this on Microsoft Windows.

9. Comment by SDPringle Sep 11, 2015

In the current change set, pi (with 20 decimal places) is reported as "too small" on ARM according to a specific user. This happened on ARM when translating the interpreter itself. I found I could reproduce this problem with numbers that have more than 1024 digits *after* the decimal on IA32. The upper limit is probably 308 or 309.

10. Comment by SDPringle Sep 15, 2015

See: hg:euphoria/rev/7b1e645eaca9

changeset: 6362:7b1e645eaca9 branch: 4.0 parent: 6339:6714730aa07a user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Tue Sep 15 23:46:16 2015 -0300 files: source/scanner.e tests/t_literals.e description:

  • ticket 877: numbers out of range give silly results: handle literals with more than 308 digits better.

11. Comment by jimcbrown Sep 16, 2015

Why was this committed only to 4.0 and not to default (since the issue as related to ARM was found on 4.1 originally)?

12. Comment by jimcbrown Sep 16, 2015

Sorry. What I meant was should we get someone to merge the changes over now or is there a reason to wait?

13. Comment by SDPringle Sep 16, 2015

The problem with PI really is a distinct problem to this one I noticed looking over the source code. First, eutest it with 4.0. Then eutest it on 4.1.

14. Comment by SDPringle Sep 22, 2015

Don't wait. You wont be able to see if there are any 64-bit or ARM problems until its merged into the default branch. So, yes please merge.

15. Comment by SDPringle Sep 25, 2015

See: hg:euphoria/rev/b87f4e1fe416

changeset: 6369:b87f4e1fe416 tag: tip user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Fri Sep 25 17:48:58 2015 -0300 files: tests/t_c_overflow_sbni.d/control.err tests/t_c_overflow_sci1.d/control.err tests/t_c_overflow_sci2.d/control.err tests/t_c_overflow_sci3.d/control.err tests/t_c_overflow_sci4.d/control.err tests/t_c_overflow_sdnf.d/control.err tests/t_c_overflow_sdni.d/control.err tests/t_c_overflow_shni.d/control.err tests/t_c_overflow_soni.d/control.err tests/t_c_underflow_sci.d/control.err tests/t_c_underflow_sdn.d/control.err description:

  • ticket 877: changed error numbers to avoid false positives for errors.

16. Comment by SDPringle Sep 26, 2015

See: hg:euphoria/rev/26fca6b707cd

changeset: 6370:26fca6b707cd branch: 4.0 parent: 6367:d3580a8616fe user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Fri Sep 25 17:48:58 2015 -0300 files: tests/t_c_overflow_sbni.d/control.err tests/t_c_overflow_sci1.d/control.err tests/t_c_overflow_sci2.d/control.err tests/t_c_overflow_sci3.d/control.err tests/t_c_overflow_sci4.d/control.err tests/t_c_overflow_sdnf.d/control.err tests/t_c_overflow_sdni.d/control.err tests/t_c_overflow_shni.d/control.err tests/t_c_overflow_soni.d/control.err tests/t_c_underflow_sci.d/control.err tests/t_c_underflow_sdn.d/control.err description:

  • ticket 877: changed error numbers to avoid false positives for errors.

17. Comment by SDPringle Oct 06, 2015

I am pleased. As far as 4.0 is concerned this is fixed. However, unit tests and code may need to be adjusted for 4.1. Compared to IA32, there are different numerical limits and a different floating point format on IA64.

18. Comment by SDPringle Oct 07, 2015

See: hg:euphoria/rev/049883ea5851

changeset: 6382:049883ea5851 user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Mon Oct 05 10:31:16 2015 -0300 files: source/scanner.e description:

  • ticket 877: added detection of scientific numbers that are read as zero but had non-zero digits

19. Comment by ne1uno Oct 09, 2015

Xp 
Euphoria Interpreter v4.1.0 development 
   32-bit Windows, Using Managed Memory 
   Revision Date: 2015-10-08 00:27:52, Id: 6391:16462e686646 
 
Interpreted test files failed unexpectedly.: 13 
These were:  
t_callc.e t_literals.e had same test failure as translated 
 
these all have "no valid ex.err has been generated." 
t_c_overflow_sbni.e t_c_overflow_sci1.e t_c_overflow_sci2.e t_c_overflow_sci3.e t_c_overflow_sci4.e t_c_overflow_sdnf.e t_c_overflow_sdni.e t_c_overflow_shni.e t_c_overflow_soni.e t_c_underflow_sci.e t_c_underflow_sdn.e 
 
Compiled test files failed unexpectedly....: 3 
These were: t_bugmagnet_15-translated.exe t_callc-translated.exe t_literals-translated.exe 
 
t_bugmagnet_15-translated.exe 	 
test name 	test time 	expected 	outcome  
Bin(5) = '5' 	0.000000 	{49,48,49} 	{48} 
Bin(50) = '110010' 	0.000000 	{49,49,48,48,49,48} 	{48} 
Bin(9000) = '10001100101000' 	0.000000 	{49,48,48,48,49,49,48,48,49,48,49,48,48,48} 	{48} 
 
 t_callc-translated.exe  
return type C_ULONGLONG makes unsigned value 	0.000000 	1.844674407e+019 	4294967295 
 
t_literals-translated.exe 
Avagadro #1 	0.000000 	6.022141e+023 	6.022141e+023 
 
 
Total Tests: 	9893 
Total Failed: 	0007 

Search



Quick Links

User menu

Not signed in.

Misc Menu