Re:Never create Ruby strings longer than 23 characters
by BudVVeezer on Wednesday December 11, 2013 @10:29AM
(#6888041)
sizeof(char) is implementation defined; see limits.h for more information on the probable size of char for your target. If the sizeof(char) is 1, the division will be optimized away, so there's no loss by keeping the code portable.
Re:Never create Ruby strings longer than 23 characters
by Sharlin on Wednesday December 11, 2013 @10:36AM
(#6888083)
No, the size of char (in bits) is implementation defined, but sizeof(char) is defined to be 1, no matter what its size in bits.
Re:Never create Ruby strings longer than 23 characters
by chollida1 on Wednesday December 11, 2013 @10:44AM
(#6888145)
No this is incorrect, see:
http://stackoverflow.com/q/4562249/25981
sizeof(char) is always defined to be one. This can't be altered by a conforming compiler.
Also (pedantic):
sizeof(char) is always 1, so that division is superfluous.