Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is an example of negative array indexing within standard lib implementations.

Functions like isprint(int c), which checks whether c is a printable ASCII character, can take as input numbers between -128 and 127 or between 0 and 255.

To achieve this, implementations usually rely on single array indexable from -128 to 255 (a lookup table).

Example from the newlib: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=new...

And the array came (indirectly) from: https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=new...



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: