sort -n, huge number
Hya,
Question With 'sort -n': How huge can numbers be? So far, I did 1. Check man page (info page as well) -> Not quite informative. (locale may be important.) 2. Experiment Code:
>cat testsort Does anybody know the answer? Happy Penguins! |
The general_numcompare() function in sort from coreutils-8.9 converts the numbers to the native long double type using the standard strtold() library function. This is used when the -g option is used.
Option -n uses strnumcmp() defined in coreutils-8.9/lib/strnumcmp-in.h, which does not do any numerical conversions. It is purely string-based, and should be able to compare any decimal number strings that fit into memory. I sincirely hope this was not homework, Nominal Animal |
I'd guess they would be limited by something like MAX_LINE -probably at least 1024 chars long -or by how much RAM you have for storing it all. You could do without the 'cat' command for faster results:
Code:
sort -n testsort |
@gnashley: Some sort implementations may have line length limits, but not GNU sort from the coreutils package. From info sort:
Quote:
Nominal Animal |
Hya
thanks! My bad! I did not think of checking the source code. This is not my homework, it is rather my job (second job). Now I feel good. The other day, I hit the size limit of long long int in C. Of course, it did not happen in test run, and it took several days to debug. I won't run into similar problem. Happy Penguins! |
All times are GMT -5. The time now is 05:28 PM. |