Cart New Account Login

HomeAbout usProductsSupportForumsBlogCustomer Service

search inside this forum
search inside all forums
Floating point translation
claudio g. Feb 23, 2018 at 04:00 AM (04:00 hours)
Staff: Takao Y.

  • Hi all,
    we have the IdeaCPU12 ide and the following build tool chain

    ---------------------------------
    COSMIC HC12/HCS12 C Compiler
    Version: 4.8.11 Date: 24 Mar 2015
    ---------------------------------
    COSMIC Software 68HC12 C Cross Compiler V4.8.9 - 29 Jan 2013 - Win32-F
    COSMIC Software 68HC12 C Parser V4.10.14 - 19 Dec 2012 - Win32-F
    COSMIC Software 68HC12 Code Generator V4.8.9 - 29 Jan 2013 - Win32-F
    COSMIC Software 68HC12 Optimizer V4.7.8 - 29 Jan 2013 - Win32
    COSMIC Software 68HC12 Macro-Assembler V4.6.26 - 22 Aug 2012 - Win32-F
    COSMIC Software Linker V4.9.5 - 06 Dec 2012 - Win32-F
    COSMIC Software Hexa Translator V4.4.9 - 23 Jan 2013 - Win32
    COSMIC Software Absolute Listing V4.4.9 - 23 Jan 2013 - Win32
    COSMIC Software Librarian V4.4.9 - 23 Jan 2013 - Win32
    COSMIC Software Absolute C Listing V4.4.9 - 23 Jan 2013 - Win32
    COSMIC Software Object Inspector V4.4.9 - 23 Jan 2013 - Win32
    COSMIC Software Print Debug Info V4.4.9 - 23 Jan 2013 - Win32
    COSMIC Software Bank Packing V4.4.9 - 23 Jan 2013 - Win32
    COSMIC Software IEEE695 Converter V7.2.3 - 15 Apr 2011 - Win32
    COSMIC Software ELF/DWARF Converter V4.6.19 - 13 Dec 2012 - Win32

    We recently found the following: we initialize some structure in code with a floating point value of 14.8f, this get translated in code to a binary representation of 0x416CCCCC (1.4799999237060546875E1 according to IEEE754), however this number is a threshold and we have another external system sending us values. When this external system sends 14.8f, its GCC compiler translates 14.8f to 0x416CCCCD (1.480000019073486328125E1 according to IEEE754). This causes the threshold to trip earlier. Question is, why would the cosmic compiler select 1.4799999237060546875E1 as the closest representation instead of 1.480000019073486328125E1?
    Is there a way to control this behavior?




    Comments

  • Greetings,

    We are not Cosmic. Please contact them to get an answer about their compiler.


    Takao Yamada

Add comment


   Want to comment? Please login or create a new PEMicro account.







© 2018 P&E Microcomputer Systems Inc.
Website Terms of Use and Sales Agreement