Do you think much about your shorts?
-
The customer ordered it, the hardware company built it, I had to program it (contract). There were no choices. The hardware company used my software to debug their firmware. (Only way to avoid finger pointing).
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
Only when targeting (a) an extremely memory-limited system, or (b) a 16-bit or less processor. (a) may be the case with industrial controllers or the first stage of a bool loader (it is an advantage if the code can run in the processor's internal memory) (b) may be the case for some embedded devices
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
-
"Not thinking" is not something I ever boasted about. It was a thought exercise; regardless of what the compiler "might do".
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
an
int
is just fine. for me, it is a no brainer. If you want to spend hours thinking about it, go for it. -
Only when targeting (a) an extremely memory-limited system, or (b) a 16-bit or less processor. (a) may be the case with industrial controllers or the first stage of a bool loader (it is an advantage if the code can run in the processor's internal memory) (b) may be the case for some embedded devices
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.
Yes. My first job was an IBM installation. Little signboards around the office, and all they said was "Think". One of the few joys left in life when you can.
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 worked with PLC's, etc. Never had to sweat 1 or 2 bytes; getting the storage architecture right was more important.
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 have always preferred the 2 bytes distribution for variables (WORD or INT) due to the endian changes, it is already painful enough to deal with it without having to increase the difficulty messing with more than a variable in the "same space" On the other hand, when staying in the PLC I have used a lot of BYTE variables. Specially when grouping bits to be masked or moved from one place to another.
M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
-
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.