[SOLVED] How do I force double to be single precision as I think I have hit a bug in the float library

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] How do I force double to be single precision as I think I have hit a bug in the float library

    Hi
    I am porting an existing firmware build from Keil and also GCC where my code works. The code is for the Nordic nrf52840 which has 32bit floating point hardware

    I have code as follows which works when built using Keil or GCC v6.3.1
    char but[64];
    float val=-3.45e+11;
    sprintf(buf,"%.2f",val)


    However when built using Segger IDE 4.12 it does not.

    What happens is that it returns from sprintf() after about 12 seconds (as opposed instantaneously for Keil & GCC) and the value in buf has no relationship with the val.
    For example, I get
    Float Value= (-4294967295.\F567295)(-3.456000e+11)

    and not the (-3.456000e+11) is correctly printed where the format string is "%e"

    I will be most grateful for any feedback/insight to go beyond this

    Look forward to hearing from you and my gratitude in advance.
  • Hello,

    Good to hear that you are up and running agian.
    As the initial inquiry has been solved this thread will be closed now.

    Best regards,
    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support contact us per e-mail.
    Alternatively our support system can be used as well: segger.com/ticket/