Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Thomas Koenig Newsgroups: comp.compilers Subject: Re: Why does the lexer convert text integer lexemes to binary integers? I thought that lexers should be simple? Date: Mon, 18 Jul 2022 05:44:05 -0000 (UTC) Organization: news.netcologne.de Lines: 33 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-07-037@comp.compilers> References: <22-07-011@comp.compilers> <22-07-015@comp.compilers> <22-07-020@comp.compilers> <22-07-032@comp.compilers> Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="75095"; mail-complaints-to="abuse@iecc.com" Keywords: lex, performance, comment Posted-Date: 18 Jul 2022 12:31:13 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:3130 George Neuner schrieb: > On Fri, 15 Jul 2022 03:02:07 -0700 (PDT), Jan Ziak ><0xe2.0x9a.0x9b@gmail.com> wrote: > >>On Friday, July 15, 2022 at 4:13:42 AM UTC+2, George Neuner wrote: >>> In many (actually most) cases, the binary representation of an integer >>> can be stored in less space than the text representation. >> >>The output of a command such as (cd /usr/src/linux; grep --only-matching >>--recursive "\b[0-9][0-9]*\b") proves the falsity of the above claim. >> >>Binary, fixed-width, representation of integers is statistically more >>space-efficient compared to implicit-width textual representation only if the >>text representation of the integers includes (for example): a plain 32/64-bit >>pointer to the start of the text, a plain 16/32/64-bit relative/absolute >>offset to the start of the number in a character array, the [length of the >>textual form of the number] in an explicit form. > > ??? > > Decimal 100 is 3 characters in text, but 1 byte in binary. ... if it is known that the number is in the range that can be represented by a single byte. If it is stored into a four-byte integer, 100 takes four bytes (obviously). If there is a length specification, it might even be longer. But of course our moderator was right when he wrote [...] > but as a message earlier today pointed out, > it's not likely to make any difference in practical compilers. -John]