Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c5608dbd720b64dd58f0a06e4ecb9c9ac326085f4dca7b14539ce3e4e884ddfd
Ticket: 63530267aa576587c112620515a2bf68870400e3
lseq.test fail on i386
User & Date: emiliano on 2023-05-07 20:27:05
Changes

  1. icomment:
    I think the test itself is misguided, as it depends on the (sometimes rather surprising) behaviour of floating point math.
    
    Besides not getting the same actual numbers on my machine, I also noted that I don't get the last (aka end) argument, 29.9 in this case.
    
    I traced this problem to generic/tclArithSeries.c , line 335
    
    	len = (dend - dstart + dstep)/dstep;
    
    len is a Tcl_WideInt argument, while the others are doubles. 
    
    For the values on this test it should be
    
    % expr {(29.9 - 1.1 + 0.3) / 0.3}
    97.0
    
    but a printf() tells me that len is 96. A second printf confirms that 
    
    	((dend - dstart + dstep)/dstep) - 97.0
    
    equals -0.00000000000000147798, so when assigned to an integral value
    it gets promoted to 96, not 97, the series resulting an element short.
    
    I think the precision issue could be solved with [format], maybe using
    
    % lmap x [lseq 1.1 29.9 0.3] {format %g $x}
    1.1 1.4 1.7 2 2.3 2.6 2.9 3.2 3.5 3.8 4.1 4.4 4.7 5 5.3 5.6 5.9 6.2 6.5 6.8 7.1 7.4 7.7 8 8.3 8.6 8.9 9.2 9.5 9.8 10.1 10.4 10.7 11 11.3 11.6 11.9 12.2 12.5 12.8 13.1 13.4 13.7 14 14.3 14.6 14.9 15.2 15.5 15.8 16.1 16.4 16.7 17 17.3 17.6 17.9 18.2 18.5 18.8 19.1 19.4 19.7 20 20.3 20.6 20.9 21.2 21.5 21.8 22.1 22.4 22.7 23 23.3 23.6 23.9 24.2 24.5 24.8 25.1 25.4 25.7 26 26.3 26.6 26.9 27.2 27.5 27.8 28.1 28.4 28.7 29 29.3 29.6
    
    Note that on this machine, using 29.900000000000001 instead of 29.9 is enough to get the extra element.
    
  2. login: "emiliano"
  3. mimetype: "text/plain"