I am trying to pass a long long type as an argument to a function and failing. I can assign 5000000000 to a long long variable as follows:
long long value = 5000000000;
But when I try to pass that variable into a method:
- (void)viewDidLoad
{
[super viewDidLoad];
long long value = 5000000000;
[self test:value];
}
-(void) test:(long long)value
{
printf("%d\n", value);
}
The value is printed as 705032704 and not 5000000000. I verified this in the debugger. The 705032704 value is constant so it seems like some kind of truncation is happening.
I’m about to start pulling my hair out with this one. Can anyone help?
Thanks,
Alan
Your printf is trying to print it as a signed int instead of long long.
Use
%lldfor long long