Ticket #525 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Floating point constants not preserved perfectly to C source

Reported by: dagss Owned by: scoder
Priority: minor Milestone: 0.13
Component: Code Generation Keywords:
Cc:

Description

The Cython code 0.1 * x gets turned into 0.10000000000000001 * x C-side.

This might not matter if one runs Cython and the C compiler on platforms with the same double representation. So in practice not a problem. But as a matter of principle, the less assumptions we make like this the better.

Change History

Changed 4 years ago by robertwb

But 0.1 *is* 0.10000000000000001 in Python.

Changed 4 years ago by robertwb

See, e.g. #190

Changed 4 years ago by scoder

Note that float.__repr__ was rewritten for Py3.1, so it will work better there (and in Py2.7). Apart from that, I'd prefer it if float constants in the C code that correspond directly to float constants in the Cython source used the exact same character sequence.

Changed 4 years ago by scoder

  • owner changed from somebody to scoder
  • status changed from new to assigned

Changed 4 years ago by scoder

  • status changed from assigned to closed
  • resolution set to fixed

Fixed here:

 http://hg.cython.org/cython-devel/rev/c103b90fdc6a

At least for normal float literals in the Cython source, this will now give the expected result.

Note: See TracTickets for help on using tickets.