Initializing variables of type long long

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Initializing variables of type long long

1,060 Views
lowpy
Contributor I

I have a problem initializing variables of type long long.

 

Normally this should work:

long long x = 0x428A2F98D728AE22LL;

 but when I compile I get the following error: C2704: Illegal number

 

Is this not supported by CW compiler or am I doing something wrong ?

 

Thanks in advance!

Labels (1)
Tags (1)
0 Kudos
6 Replies

580 Views
Lundin
Senior Contributor IV

I believe neither the HCS08 nor the HCS12 Codewarrior supports C99. If you need to use C99 features, the first thing you should do is to get a C99 compiler.

0 Kudos

580 Views
BlackNight
NXP Employee
NXP Employee

Hello,

yes, 64bit integers are not supported. long long is supported with 32bit max.

Anyway, doing 64bit math with a HCS08 or HCS12 will be rather a performance bottleneck.

So if you are using a 8 or 16bit processor for 64bit math, you might use the wrong cpu for it.

 

BK

0 Kudos

580 Views
lowpy
Contributor I

Let me just see it I got this right.

 

Even if I manage to initialize the variable in another way, operations on that variable will only affect the lower 32 bits ?

0 Kudos

580 Views
bigmac
Specialist III

Hello,

 

Your variable could be treated as an array of two double words, four words, or eight bytes, or maybe a union of all three to provide greater flexibility.  Arithmetic operations would then need to be performed on the individual array elements.

 

Regards,

Mac

 

0 Kudos

580 Views
BlackNight
NXP Employee
NXP Employee

sizeof(long long) will return 4, means it occupies 4 bytes (32bit) in memory. You will only have 32bit available.

An alternative would be to use/implement a software library, with something like

int64_t Add64(int64_t, int64_t);

I did not check, but maybe things like that is already awailable as open source.

 

BK

0 Kudos

580 Views
kef
Specialist I

What if lossless 64bit computation is required one or few times per second? Even 4-bits MCU can do it.

0 Kudos