gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: long long unsigned on 32-bit machines


From: Sanjeev Gupta
Subject: Re: long long unsigned on 32-bit machines
Date: Sun, 26 Jan 2020 21:21:11 +0800

On Sun, Jan 26, 2020 at 3:42 PM Hal Murray <address@hidden> wrote:

You can cast the thing you want to print to (unsigned) long long and use ll.

printf("%llu"\n", (unsigned long long)t);

That makes sense to me.  But ...

Followup question.  Why does 'i' need to be 64 bits?   Or even 32?

    (void)wmove(navfixwin, 11, 6);
    {
        char prn[4], satlist[38];
        uint64_t i;         // uint64_t just in case ints are 32-bit
        satlist[0] = '\0';
        for (i = 0; i < 32; i++) {
            if (svlist & (1 << i)) {
                (void)snprintf(prn, 4, "%lu ", i + 1);
                (void)strlcat(satlist, prn, sizeof(satlist));
            }
        }
        (void)wprintw(navfixwin, "%02d = %-38s", nsv, satlist);
    }

 
I think we should wait for Bernd to chime in.

--
Sanjeev

reply via email to

[Prev in Thread] Current Thread [Next in Thread]