Possible Duplicate:
how do you divide two integers and get a decimal answer?
This is probably really easy but I can’t find the solution. I’m not a “real” programmer…
I’m storing number and scores on my app using int_64.
.h
int64_t score;
@property (nonatomic, assign) int64_t score;
.m
@synthesize score;
Here is the math:
self.score = 7/3;
The result is “2”, instead of “2.33333…”. I should use use something different from int_64, but what?
I wanted the result to be “2,33”, with two digits after the comma. Can anyone help? Thanks!
intstores whole numbers, also called integers. For calculations with a fractional part usedouble.Also, it’s better to fix the number of digits is when formatting for display. For example: