[EXT_EP-10056] Rounding error in floating point division of constant values Created: 23/Sep/20  Updated: 16/Nov/23

Status: Accepted
Project: Embedded Software & Tools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Low
Reporter: TI User Assignee: TI User
Resolution: Unresolved Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Product: Code Generation Tools
Internal ID: CODEGEN-8214
Forum URL: https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/942961
Found In Release: C2000_22.6.0.LTS
C2000_21.6.0.LTS
C2000_20.2.2.LTS
Affected Platform/Device: default

 Description   

The attached file contains this line ...

   if (delay  >= ( (unsigned short) (20e-3/(1e-3)) ) )

Thus, you would expect the variable delay to be compared with the value 20.

Build it ...

% cl2000 -s try1.c

Then inspect the resulting assembly file to see these lines ...

;----------------------------------------------------------------------
;   5 | if (delay  >= ( (unsigned short) (20e-3/(1e-3)) ) )
;----------------------------------------------------------------------
        MOVW      DP,#_delay            ; [CPU_ARAU]
        MOV       AL,@_delay            ; [CPU_ALU] |5|
        CMPB      AL,#19                ; [CPU_ALU] |5|
        B         $C$L1,LO              ; [CPU_ALU] |5|

It is not compared again 20, but 19.

 


Generated at Wed Apr 02 18:08:50 CDT 2025 using Jira 9.12.17#9120017-sha1:aba4002bcd633f188b6a4bb5dd8a0e1f20b79ee4.