-6

I'm looking into fortify issues identified in some open source C code our service uses and see code like this;

..
} else if (n < (1024LL*1024*1024)) {
..

What is the significance of the LL on 1024LL as opposed to just 1024? Thanks.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621

1 Answers1

2

LL is a suffix that means long long. In that particular snippet of code, the writer is saying one of the terms is 1024 but stored in a long long way. C has a rule that says the largest bits of any of the terms will be what it uses when it resolves integer math. Without the LL, then, 1024 * 1024 * 1024 would just overflow.

TJ Bandrowsky
  • 842
  • 8
  • 12
  • "C has a rule that says the largest bits of any of the terms will be what it uses when it resolves integer math" --> Yes (use highest rank) for 2 terms, no for 3 terms as all are done 2 terms at a time. – chux - Reinstate Monica Jan 04 '19 at 19:14
  • `1024 * 1024 * 1024` would not overflow 32-bit `int`. Still `1024LL*1024*1024` is a good [idea](https://stackoverflow.com/a/40637622/2410359). – chux - Reinstate Monica Jan 04 '19 at 19:15