How to take the sum of all the values in an array ?
1 view (last 30 days)
Show older comments
I have a Data in java. math.BigInteger format.
Data =
java.math.BigInteger[]:
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
[java.math.BigInteger]
For any two values we can add like this
result = Data(1).add(Data(2))
But how can we add all the values in the large Data?
2 Comments
Accepted Answer
David Hill
on 12 Oct 2022
import java.math.*
s=BigInteger('0');
for k=1:length(Data)
s=s.add(Data(k));
end
More Answers (0)
See Also
Categories
Find more on Call Java from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!