Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3923

C/C++ • Re: How long is a long integer on the various types of raspberryPi ?

$
0
0
It depends on the OS architecture, not necessarily the PI hardware (as 32-bit OS can run on any Pi).

A 64 bit OS (arm64) will result in

Code:

ffffffffffffffffffffffffffffffff
and a 32 bit OS (armhf) will show

Code:

ffffffffffffffffffffffff
I added a sizeof() to your printf to show that more clearly

Code:

#include <stdio.h>int main(){    long l;    long long ll;    ll = 0x0;    ll = ll - 1;;    printf("[%d] %llx\n", sizeof(ll), ll);    l = 0x0;    l = l - 1;;    printf("[%d] %lx\n", sizeof(l), l);}
64-bit OS:

Code:

[8] ffffffffffffffff[8] ffffffffffffffff
32-bit OS:

Code:

[8] ffffffffffffffff[4] ffffffff

Statistics: Posted by rpdom — Fri Nov 01, 2024 2:35 pm



Viewing all articles
Browse latest Browse all 3923

Trending Articles