Do you think much about your shorts?
-
In looking at this JPL/Nasa code, it makes references to doing this and that for "performance". In some cases, their loop variable is an int; in others a short; in others a long. Given a choice which is best? Probably an int, unless you "need" a long. Ironic that for the sake of "storage" (2 bytes), they've sacrificed performance. [asp.net - Why should I use int instead of a byte or short in C# - Stack Overflow](https://stackoverflow.com/questions/1097467/why-should-i-use-int-instead-of-a-byte-or-short-in-c-sharp)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
More so now because of winter my legs are shockingly white.
I'm not sure how many cookies it makes to be happy, but so far it's not 27. JaxCoder.com
-
In looking at this JPL/Nasa code, it makes references to doing this and that for "performance". In some cases, their loop variable is an int; in others a short; in others a long. Given a choice which is best? Probably an int, unless you "need" a long. Ironic that for the sake of "storage" (2 bytes), they've sacrificed performance. [asp.net - Why should I use int instead of a byte or short in C# - Stack Overflow](https://stackoverflow.com/questions/1097467/why-should-i-use-int-instead-of-a-byte-or-short-in-c-sharp)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
It depends on the target environment. I work on HPC stuff using CUDA and GPUs and with them using a short instead of an int can make a significant difference in performance and Nvidia includes this point in their documentation. With CUDA, using an signed value is almost always preferred over an unsigned value for performance reasons also. They have quite a number of odd, little quirks regarding optimal performance. For standard desktop CPUs I rarely concern myself with that issue. The only other environment I work in these days is embedded code in scanning cameras and I don't care there either.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
-
In looking at this JPL/Nasa code, it makes references to doing this and that for "performance". In some cases, their loop variable is an int; in others a short; in others a long. Given a choice which is best? Probably an int, unless you "need" a long. Ironic that for the sake of "storage" (2 bytes), they've sacrificed performance. [asp.net - Why should I use int instead of a byte or short in C# - Stack Overflow](https://stackoverflow.com/questions/1097467/why-should-i-use-int-instead-of-a-byte-or-short-in-c-sharp)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
This morning I took my dog out for a romp. it was -18 out. I remembered how I used to wear shorts at the same time of day in the summer.
-
In looking at this JPL/Nasa code, it makes references to doing this and that for "performance". In some cases, their loop variable is an int; in others a short; in others a long. Given a choice which is best? Probably an int, unless you "need" a long. Ironic that for the sake of "storage" (2 bytes), they've sacrificed performance. [asp.net - Why should I use int instead of a byte or short in C# - Stack Overflow](https://stackoverflow.com/questions/1097467/why-should-i-use-int-instead-of-a-byte-or-short-in-c-sharp)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
original Apollo 11 guidance computer was 16bit someone said this was a rework from FORTRAN to C maybe this is indeed for 16bit hardware
-
Oh Well, I wish you would have commented sooner. I found a bug in your json parser but didn't want to tarnish your article comment section. :-O Let me know if you want to discuss it here and I'll go over and delete it.
I'm about to fix it. I was at sister's yesterday so I couldn't.
Real programmers use butterflies
-
In looking at this JPL/Nasa code, it makes references to doing this and that for "performance". In some cases, their loop variable is an int; in others a short; in others a long. Given a choice which is best? Probably an int, unless you "need" a long. Ironic that for the sake of "storage" (2 bytes), they've sacrificed performance. [asp.net - Why should I use int instead of a byte or short in C# - Stack Overflow](https://stackoverflow.com/questions/1097467/why-should-i-use-int-instead-of-a-byte-or-short-in-c-sharp)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
NASA spacecraft still run on 286 instruction sets, so it would depend on where the code is being run. Space center code would be a different architecture. EDIT: PowerPC
-
In looking at this JPL/Nasa code, it makes references to doing this and that for "performance". In some cases, their loop variable is an int; in others a short; in others a long. Given a choice which is best? Probably an int, unless you "need" a long. Ironic that for the sake of "storage" (2 bytes), they've sacrificed performance. [asp.net - Why should I use int instead of a byte or short in C# - Stack Overflow](https://stackoverflow.com/questions/1097467/why-should-i-use-int-instead-of-a-byte-or-short-in-c-sharp)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
I don't, I just grab the first pair out of the drawer. Oh, shorts, Keystone cops? Pink Panther? --NASA they could be using an 8 bit CPU. More likely a 16 bit, but probably not something that's not 16 bit word directly addressable. Shorts may be faster access. When and for what was the code written?
-
You make a lot of assumptions.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
-
In looking at this JPL/Nasa code, it makes references to doing this and that for "performance". In some cases, their loop variable is an int; in others a short; in others a long. Given a choice which is best? Probably an int, unless you "need" a long. Ironic that for the sake of "storage" (2 bytes), they've sacrificed performance. [asp.net - Why should I use int instead of a byte or short in C# - Stack Overflow](https://stackoverflow.com/questions/1097467/why-should-i-use-int-instead-of-a-byte-or-short-in-c-sharp)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
Quote:
In some cases, their loop variable is an int; in others a short; in others a long. Given a choice which is best?
Use a size_t, unless you have a specific reason that needs negative numbers. The reason is because the compiler can warn you if you are writing a loop that may never terminate (checking for <=0 zero, for example). For fast execution reasons, use unsigned int or int as they are guaranteed to be the natural word size of the platform. For space reasons using 8 bit and 16 bit integers make sense, but don't use 'short' or 'long' etc, they are not guaranteed to have any specific width. If you need a specific bit width use uint8_t/int8_t/int_least8_t/uint_least8_t and their 16, 32 and 64 counterparts. Using 'short' and writing code that assumes it is 16-bit or using 'int' and writing code that operates on it as a 32 bit integer is guaranteed to break on some platform; those are latent bugs because overflows are undefined behaviour and the compiler is allowed to generate code that crashes when you overflow a signed integer type (yes, that's happened to me on at least one ARM platform when compiled with clang and -O3). In general, avoid using bare int/short/long long/long because the compiler cannot warn you if you are writing bugs.
-
In looking at this JPL/Nasa code, it makes references to doing this and that for "performance". In some cases, their loop variable is an int; in others a short; in others a long. Given a choice which is best? Probably an int, unless you "need" a long. Ironic that for the sake of "storage" (2 bytes), they've sacrificed performance. [asp.net - Why should I use int instead of a byte or short in C# - Stack Overflow](https://stackoverflow.com/questions/1097467/why-should-i-use-int-instead-of-a-byte-or-short-in-c-sharp)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
In the old days we had to worry about every byte of memory and every tick of the clock, but with modern computers, it goes without saying that memory and speed are rarely limiting, unless: you were looping objects or something large, or you were designing a real-time app like a missile-tracking system. Some coders opt for 'better performance' even when it actually makes no significant difference, simply because they can.