Article View: pl.comp.lang.c
Article #309446Re: chunk2int (or str2int) how it SHOULD work?
From: dawid.bautsch
Date: Fri, 15 Sep 2017 12:20
Date: Fri, 15 Sep 2017 12:20
13 lines
2247 bytes
2247 bytes
My proposition is to split the whole process into three stages. Stage 1: The input string has to be split by lines. The function will try to separate each number. Here you must make an assumption: at least two spaces (or even one if you wish, or tab character) are used to separate number. Stage 2: input data normalization. Removing non numeric data, white spaces and so on from each extracted element. There are some corner case here: * if the input string contains "0x" symbol, then we treat it like a hex string literal. * if the input string begins with "." or "," then we assume it is a float number. Stage 3: Converting ascii (or unicode) symbols into number. PS> Example trash input data : "a-22-3" This is an invalid number. It could be read as "22" or "223". Both of them are invalid i suspose. So it should be discarded during first stage.
Technical Details
Message-ID:
<d8c69713-0a0f-4664-8349-1ddd667e401f@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer02.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!q8no723096qtb.0!news-out.google.com!x15ni226qth.1!nntp.google.com!q8no723092qtb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailReferences:
<f762205f-d614-4267-813a-f181066a6ae2@googlegroups.com>Show Full Headers
Complete Article Headers
X-Received: by 10.129.96.132 with SMTP id u126mr15682538ywb.70.1505478030403; Fri, 15 Sep 2017 05:20:30 -0700 (PDT) X-Received: by 10.31.140.78 with SMTP id o75mr340393vkd.29.1505478030349; Fri, 15 Sep 2017 05:20:30 -0700 (PDT) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer02.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!q8no723096qtb.0!news-out.google.com!x15ni226qth.1!nntp.google.com!q8no723092qtb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: pl.comp.lang.c Date: Fri, 15 Sep 2017 05:20:30 -0700 (PDT) In-Reply-To: <f762205f-d614-4267-813a-f181066a6ae2@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=89.25.216.1; posting-account=kSehUwoAAABY25ms1-AAR--etdS3BVdP NNTP-Posting-Host: 89.25.216.1 References: <f762205f-d614-4267-813a-f181066a6ae2@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <d8c69713-0a0f-4664-8349-1ddd667e401f@googlegroups.com> Subject: Re: chunk2int (or str2int) how it SHOULD work? From: dawid.bautsch@gmail.com Injection-Date: Fri, 15 Sep 2017 12:20:30 +0000 X-Received-Body-CRC: 1137658179 X-Received-Bytes: 2098 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit