Multiply large numbers in objective-c -


i have tried multiply large integers (also tried double) in xcode. used nslog track errors in calculation (simple calculations) , noticed when multiply variables large values such (i looked them nslog): 31536000 * 91 = 2869776000 1610612736, wrong. do wrong?

/d

what type of data use numbers? if nsinteger, or that, it's close standard int, has limitation.

for example, on standard 64 bits architecture can declare long long int permits have 64 bits integer. if multiplication requires more place, left bits may truncated, changes result.

you use long double, permits handle 80 bits numbers extended double precision, still loose precision on big numbers.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -