• AVR Freaks

Hot!printf with %lld and %f not working

Author
dom11990
New Member
  • Total Posts : 21
  • Reward points : 0
  • Joined: 2013/01/12 14:29:00
  • Location: 0
  • Status: offline
2020/04/29 05:18:10 (permalink)
0

printf with %lld and %f not working

Hi,
 
I'm trying to print some u64 values with %lld and it creates total nonsense. Same goes for %f with a double or a float value. Im on version 2.4. Should this not be possible?
 
Device is a PIC32MX270F256B
 
cheers
dominik
#1

9 Replies Related Threads

    andersm
    Super Member
    • Total Posts : 2798
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: online
    Re: printf with %lld and %f not working 2020/04/29 06:57:24 (permalink)
    +1 (1)
    For long longs, see eg. this thread. For floats, check if you are building with 32- or 64-bit doubles.
    #2
    dom11990
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2013/01/12 14:29:00
    • Location: 0
    • Status: offline
    Re: printf with %lld and %f not working 2020/04/29 08:45:09 (permalink)
    0
    Thank you for the reply. How would I check if I am building 32 or 64 bit doubles? Are one of the two not supported?
     
     
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 18667
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: printf with %lld and %f not working 2020/04/29 10:10:04 (permalink)
    +1 (1)
    Check You Project settings to see which mode it is set to.
    #4
    dom11990
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2013/01/12 14:29:00
    • Location: 0
    • Status: offline
    Re: printf with %lld and %f not working 2020/04/29 10:44:48 (permalink)
    0
    Apparently I am too dumb. Could you ELI5 where this setting is? I don't see anything related to floats or doubles in the project settings.
    #5
    lachlanp
    New Member
    • Total Posts : 5
    • Reward points : 0
    • Joined: 2018/03/27 02:03:54
    • Location: 0
    • Status: offline
    Re: printf with %lld and %f not working 2020/04/29 17:44:55 (permalink)
    0
    I am using XC32 with SAMD21 ARM device. I have the same problem.
    I recall that looking through many old posts on this problem that it appears that XC32 does not support float in printf so I had to write my own.
    If you find that printf does support floats, please post how to activate it.
    #6
    jdeguire
    Super Member
    • Total Posts : 555
    • Reward points : 0
    • Joined: 2012/01/13 07:48:44
    • Location: United States
    • Status: offline
    Re: printf with %lld and %f not working 2020/04/30 10:58:45 (permalink)
    -1 (1)
    MPLAB X v2.40 should be assuming that a 'double' is 64-bit on all platforms.  For ARM devices, it was always 64-bit.  For MIPS devices, it used to be 32-bit ('long double' was still 64-bit).
    #7
    dom11990
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2013/01/12 14:29:00
    • Location: 0
    • Status: offline
    Re: printf with %lld and %f not working 2020/05/01 01:38:10 (permalink)
    0
    So is the final answer then printf with doubles is not possible?
    #8
    LostInSpace
    Super Member
    • Total Posts : 306
    • Reward points : 0
    • Joined: 2016/03/11 22:47:59
    • Location: 0
    • Status: offline
    Re: printf with %lld and %f not working 2020/05/22 21:48:24 (permalink)
    0
    If you look through the compiler release notes you will see that they say that using the "Legacy Libc" fixes some sscanf stuff, well for me it also fixes all the printf float and double issues I had along with a lot of other functions that never seemed to work right, they also say that this is now the "default setting", although it has never come on as a default for me, I always have to manually click it. Also they have changed from float and double being the same to now float and double are as you would suspect, actually floats and doubles. Read the release notes carefully for your compiler version.
     
     
    #9
    dom11990
    New Member
    • Total Posts : 21
    • Reward points : 0
    • Joined: 2013/01/12 14:29:00
    • Location: 0
    • Status: offline
    Re: printf with %lld and %f not working 2020/05/23 02:22:25 (permalink)
    +1 (1)
    Thank you for your reply, however, I've moved away from PICs now for new development projects. Perhaps I am naive but I don't want to spend time trying to get basic standard library functions to work. This is also not the first time that "simple" things don't work only to find out it is either not implemented or a bug. Although the magnitude of this fix appears small, it is the final straw for me. Not to mention, I don't know what the impact to other code is when setting that checkbox.
     
    Some things should "just work" out of the box; this is one of them.  I think the fact that it doesn't casts a large shadow on the reliability of the platform. This is too much risk for us in commercial applications.
    #10
    Jump to:
    © 2020 APG vNext Commercial Version 4.5