|
|
1.1 ! root 1: /* @(#)ltostr.c 1.1 */ ! 2: /* ! 3: * ltostr -- convert long to decimal string ! 4: * ! 5: * ! 6: * char * ! 7: * ltostr(value, ptr) ! 8: * long value; ! 9: * char *ptr; ! 10: * ! 11: * Ptr is assumed to point to the byte following a storage area ! 12: * into which the decimal representation of "value" is to be ! 13: * placed as a string. Ltostr converts "value" to decimal and ! 14: * produces the string, and returns a pointer to the beginning ! 15: * of the string. No leading zeroes are produced, and no ! 16: * terminating null is produced. The low-order digit of the ! 17: * result always occupies memory position ptr-1. ! 18: * Ltostr's behavior is undefined if "value" is negative. A single ! 19: * zero digit is produced if "value" is zero. ! 20: * ! 21: */ ! 22: ! 23: char * ! 24: ltostr(value, ptr) ! 25: register long value; ! 26: register char *ptr; ! 27: { ! 28: register long t; ! 29: ! 30: do { ! 31: *--ptr = '0' + value - 10 * (t = value / 10); ! 32: } while ((value = t) != 0); ! 33: ! 34: return(ptr); ! 35: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.