4 ms·
Well, in C++ int('1' * 4301) is a perfectly valid expression, but it evaluates to 210749, not 4301.
by gsliepen 4y ago
Well, in C++ int('1' * 4301) is a perfectly valid expression, but it evaluates to 210749, not 4301.
- oldgradstudent 4y agoOr some other value. If sizeof(int)=2, the result is undefined.
- gsliepen 4y agoNot if CHAR_BIT is 10 or more!
- oldgradstudent 4y agoI wonder how much software will fail on platforms where CHAR_BIT is not 8.
- Kamq 4y agoI've seen 2 programs in my life that checked for CHAR_BIT (and one was a toy decimal -> binary converter). My guess is basically all of it.
- AlotOfReading 4y agoI worked with some MCUs whose only redeeming quality was their cost that had CHAR_BIT=16. The answer is basically everything. It made string processing was profoundly annoying, even for C.
- colejohnson66 4y agoIs it one of TI’s custom ISAs for their DSP line? The TMS430, for example, has a 16 bit char. That causes some unintuitive looking code to fight that.
- AlotOfReading 4y agoNo, it was with xap [1] chips. TI is also on my list of annoying chip vendors because they're one of the few companies still making big endian ARM chips, which should die in a fire. [1] https://en.wikipedia.org/wiki/XAP_processor https://en.wikipedia.org/wiki/XAP_processor
- eMSF 4y agoWhether evaluating that expression results in undefined behaviour also depends on the basic execution character set and the bit width of the machine byte.
- dark-star 4y agoit doesn't evaluate to 4301 in Python either ;-)