Opened 6 years ago

Closed 6 years ago

#525 closed defect (fixed)

Floating point constants not preserved perfectly to C source

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


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 (5)

comment:1 Changed 6 years ago by robertwb

But 0.1 *is* 0.10000000000000001 in Python.

comment:2 Changed 6 years ago by robertwb

See, e.g. #190

comment:3 Changed 6 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.

comment:4 Changed 6 years ago by scoder

  • Owner changed from somebody to scoder
  • Status changed from new to assigned

comment:5 Changed 6 years ago by scoder

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed here:

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.