News for hackers. Stuff that matters.
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.

Re:Never create Ruby strings longer than 23 characters by EpicEng on Wednesday December 11, 2013 @02:15PM (#6889884)
Wrong. sizeof(char) is define to be one. The number of bits in a byte (char) is implementation defined (this is why CHAR_BIT exists). Not the same thing.