Problem 1731. Text File Read: 64 bit data set
This Challenge is to read a text file that has vary large integers up to 2e18, typical for Google Code Jam. These values are well within the bounds of uint64.
The data is an array of Q pairs.
Input: [Q, fname] The number of lines in the file and its filename.
Output: M a uint64 matrix of size(Q,2)
Example:
Input: {4, 'Cody_64.txt']
The text file:
308436464205151562 1850618785230909388
373665302816212423 1494661211264849698
760961177192651897 1521922354385303795
1 2000000000000000000
Ouput: A uint64 (4,2) matrix to full precision.
Note of Warning:
The fscanf function with %ul may not succeed, as of 7/20/2013.
The result window has a case showing the function output
Related Challenges:
1) Bullseye Large Numbers r<1E18, P<2E18
2) Super Large Numbers >2^64 (Java BigInteger methods)
Solution Stats
Problem Comments
-
3 Comments
Nikolaos Nikolaou
on 27 Dec 2021
That was painful to lear xD .
Btw i really think its about time some document the capabilities of str2num properly ( i mean the eval like capabilties)
ChrisR
on 27 Mar 2022
The file 'Cody_64.txt' is missing in the first two tests. It could be created using the code in the third test (and changing the file name).
Christian Schröder
on 28 Mar 2023
> The fscanf function with %ul may not succeed, as of 7/20/2013.
The correct format identifier is %lu --- using that, it works.
Solution Comments
Show commentsProblem Recent Solvers13
Suggested Problems
-
All your base are belong to us
541 Solvers
-
567 Solvers
-
605 Solvers
-
Flip the main diagonal of a matrix
809 Solvers
-
302 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!