Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #59511 > unrolled thread

strtoll discussion

Started byjacobnavia <jacob@jacob.remcomp.fr>
First post2015-04-03 14:28 +0200
Last post2015-04-07 11:46 +0200
Articles 20 on this page of 79 — 19 participants

Back to article view | Back to comp.lang.c


Contents

  strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-03 14:28 +0200
    Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-03 14:46 +0100
    Re: strtoll discussion Keith Thompson <kst-u@mib.org> - 2015-04-03 11:08 -0700
    Re: strtoll discussion James Kuyper <jameskuyper@verizon.net> - 2015-04-03 15:23 -0400
      Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-03 20:55 +0100
        Re: strtoll discussion glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-04-03 20:41 +0000
          Re: strtoll discussion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-03 13:52 -0700
            Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-03 22:25 +0100
              Re: strtoll discussion Bartc <bc@freeuk.com> - 2015-04-04 00:17 +0100
                Re: strtoll discussion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-03 16:27 -0700
              Re: strtoll discussion Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-04 02:07 +0100
                Re: strtoll discussion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-04 03:44 -0700
                  Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-04 12:13 +0100
      Re: strtoll discussion James Kuyper <jameskuyper@verizon.net> - 2015-04-03 16:11 -0400
      Re: strtoll discussion Keith Thompson <kst-u@mib.org> - 2015-04-03 14:12 -0700
      Re: strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-03 23:56 +0200
    Re: strtoll discussion Ian Collins <ian-news@hotmail.com> - 2015-04-04 08:41 +1300
      Re: strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-03 23:33 +0200
    Re: strtoll discussion James Lothian <james@firstnamelastname.freeserve.co.uk> - 2015-04-03 20:51 +0100
      Re: strtoll discussion asetofsymbols@gmail.com - 2015-04-03 13:09 -0700
        Re: strtoll discussion asetofsymbols@gmail.com - 2015-04-03 13:16 -0700
        Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-03 21:19 +0100
          Re: strtoll discussion asetofsymbols@gmail.com - 2015-04-03 13:28 -0700
            Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-03 22:29 +0100
            Re: strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-03 23:33 +0200
        Re: strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-03 23:34 +0200
          Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-03 22:42 +0100
            Re: strtoll discussion Keith Thompson <kst-u@mib.org> - 2015-04-03 15:08 -0700
            Re: strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-04 00:13 +0200
              Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-03 23:44 +0100
                Re: strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-04 00:48 +0200
                  Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-04 00:03 +0100
                  Re: strtoll discussion Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-04-03 19:31 -0400
                    Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-04 00:37 +0100
                      Re: strtoll discussion Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-04-04 10:29 -0400
                        Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-04 15:54 +0100
                        Re: strtoll discussion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-04 08:07 -0700
                          Re: strtoll discussion Bartc <bc@freeuk.com> - 2015-04-04 16:28 +0100
                            Re: strtoll discussion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-04 08:57 -0700
                              Re: strtoll discussion Bartc <bc@freeuk.com> - 2015-04-04 17:03 +0100
                                Re: strtoll discussion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-04 09:44 -0700
                                  Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-04 18:05 +0100
                                    Re: strtoll discussion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-04 23:32 -0700
                                      Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-05 11:00 +0100
                                        Re: strtoll discussion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-05 13:18 -0700
                                          Re: strtoll discussion Richard Damon <Richard@Damon-Family.org> - 2015-04-05 17:37 -0400
                                            Re: strtoll discussion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-04-05 15:00 -0700
                                              Re: strtoll discussion Robert Wessel <robertwessel2@yahoo.com> - 2015-04-05 22:17 -0500
                            Re: strtoll discussion Richard Damon <Richard@Damon-Family.org> - 2015-04-04 18:54 -0400
                              Re: strtoll discussion Bartc <bc@freeuk.com> - 2015-04-05 12:14 +0100
                    Re: strtoll discussion glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-04-04 00:19 +0000
                  Re: strtoll discussion Keith Thompson <kst-u@mib.org> - 2015-04-03 17:48 -0700
                  Re: strtoll discussion James Kuyper <jameskuyper@verizon.net> - 2015-04-08 11:23 -0400
                    Re: strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-08 19:35 +0200
                    Re: strtoll discussion Keith Thompson <kst-u@mib.org> - 2015-04-08 10:47 -0700
                      Re: strtoll discussion James Kuyper <jameskuyper@verizon.net> - 2015-04-08 14:22 -0400
    lltostr/ulltostr jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-04 13:56 +0200
      Re: lltostr/ulltostr Richard Heathfield <rjh@cpax.org.uk> - 2015-04-04 13:36 +0100
      Re: lltostr/ulltostr Barry Schwarz <schwarzb@dqel.com> - 2015-04-04 18:54 -0700
        Re: lltostr/ulltostr Ian Collins <ian-news@hotmail.com> - 2015-04-05 14:29 +1200
      Re: lltostr/ulltostr Ralf Damaschke <rwspam@gmx.de> - 2015-04-05 16:58 +0000
        Re: lltostr/ulltostr jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-05 20:39 +0200
          Re: lltostr/ulltostr glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-04-05 20:19 +0000
        Re: lltostr/ulltostr Keith Thompson <kst-u@mib.org> - 2015-04-05 13:18 -0700
          Re: lltostr/ulltostr Ralf Damaschke <rwspam@gmx.de> - 2015-04-06 14:28 +0000
            Re: lltostr/ulltostr Keith Thompson <kst-u@mib.org> - 2015-04-06 08:40 -0700
    Re: strtoll discussion Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-04 13:04 -0700
      Re: strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-04 22:52 +0200
        Re: strtoll discussion Richard Heathfield <rjh@cpax.org.uk> - 2015-04-04 22:14 +0100
        Re: strtoll discussion Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-05 00:24 +0100
        Re: strtoll discussion Geoff <geoff@invalid.invalid> - 2015-04-04 16:51 -0700
        Re: strtoll discussion jacobnavia <jacob@jacob.remcomp.fr> - 2015-04-05 23:32 +0200
          Re: strtoll discussion Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-16 09:21 -0700
        Re: strtoll discussion Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-17 02:21 -0700
      Re: strtoll discussion Keith Thompson <kst-u@mib.org> - 2015-04-04 15:36 -0700
        Re: strtoll discussion Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-16 09:19 -0700
          Re: strtoll discussion Keith Thompson <kst-u@mib.org> - 2015-04-16 10:43 -0700
            Re: strtoll discussion Tim Rentsch <txr@alumni.caltech.edu> - 2015-04-17 07:59 -0700
    Re: strtoll discussion Philipp Klaus Krause <pkk@spth.de> - 2015-04-07 11:46 +0200

Page 1 of 4  [1] 2 3 4  Next page →


#59511 — strtoll discussion

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2015-04-03 14:28 +0200
Subjectstrtoll discussion
Message-ID<mfm0uu$i18$1@dont-email.me>
Hi

I have written a document about the discusssion that we had in this 
group. It would be nice to give to newcomers here, so that they can read 
non-trivial code that is well documented.

There was a wiki project that was started long ago but didn't go further 
because of copyright problems with Mr Plaugher.

Is that  still active? Could I upload the pdf there?

I have written the names of the people that participated in the 
document. Is that OK with you?

The URL is:

http://www.cs.virginia.edu/~lcc-win32/strtoll.pdf

[toc] | [next] | [standalone]


#59517

FromRichard Heathfield <rjh@cpax.org.uk>
Date2015-04-03 14:46 +0100
Message-ID<mfm5iv$4gd$1@dont-email.me>
In reply to#59511
On 03/04/15 13:28, jacobnavia wrote:
<snip>
>
> There was a wiki project that was started long ago but didn't go further
> because of copyright problems with Mr Plaugher.
>
> Is that  still active? Could I upload the pdf there?

Excellent idea. I'd forgotten about the clc wiki.

http://www.clc-wiki.net/

According to the News page, the software was upgraded on 28/11/2014, so 
presumably it's not completely dead! (And for all I know, it may be 
buzzing with activity.) Worth a try, anyway.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#59536

FromKeith Thompson <kst-u@mib.org>
Date2015-04-03 11:08 -0700
Message-ID<87zj6pxex6.fsf@kst-u.example.com>
In reply to#59511
jacobnavia <jacob@jacob.remcomp.fr> writes:
> I have written a document about the discusssion that we had in this
> group. It would be nice to give to newcomers here, so that they can
> read non-trivial code that is well documented.
>
> There was a wiki project that was started long ago but didn't go
> further because of copyright problems with Mr Plaugher.
>
> Is that  still active? Could I upload the pdf there?
>
> I have written the names of the people that participated in the
> document. Is that OK with you?
>
> The URL is:
>
> http://www.cs.virginia.edu/~lcc-win32/strtoll.pdf

I have no objection to your inclusion of my name.

I haven't had a chance to look it over.  What little I've had time to
read looks good.  I'll try to spend some time on it this weekend.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#59540

FromJames Kuyper <jameskuyper@verizon.net>
Date2015-04-03 15:23 -0400
Message-ID<551EE8B7.4020106@verizon.net>
In reply to#59511
On 04/03/2015 08:28 AM, jacobnavia wrote:
> Hi
> 
> I have written a document about the discusssion that we had in this 
> group. It would be nice to give to newcomers here, so that they can read 
> non-trivial code that is well documented.

You wrote "I’m not really defending the way the strto*() functions are
designed, but given what they do allowing any integer base 2-36 is
really only a tiny bit of overdesign compared to allowing only a few
bases in that range."
I'm somewhat confused by the description of that as "overdesign", even
though it's "only a tiny bit". It's true that the bases 2, 4, 8, 10, 16,
and 32 are probably overwhelmingly the most commonly used, with 4 and 32
being used less often than the others. However, I don't see how any
advantage could be derived from disallowing other bases. The reason
depends upon upon what you're thinking of as a less-overdesigned
alternative, but I reach the same conclusion either way.

1. Mandating that an error indication of some kind be returned if any
other base is requested. This would complicate the code, and (very!)
marginally slow it down - with no apparent benefit.

2. Allowing the behavior to be undefined if the any other base is used.
There would be a point to doing this if there were any reasonable way to
make the code faster or otherwise better in some way, by writing it in
some way that fails for the other bases. The key problem: I can't
imagine what that other way might be.. The simple, obvious code for
handling base == 2, 4, 8, 10, 16, and 32 also incidentally correctly
handles any base from 3 to 31; with negligible changes, that same code
will handle any base up to 36.

Very few people want to use any other base - but I'm sure there are
some, and there's no good reason to force them to write their own code
to do the same thing that is already done, at no extra cost, by the most
obvious code for strtoll().

You also wrote:
"Another problem with the base specification is that there is no
standard function to output numbers with an arbitrary base!"

I'm a little confused by that comment - there is such a function, and
it's name is strtoll(), and you're implementing it.

[toc] | [prev] | [next] | [standalone]


#59544

FromRichard Heathfield <rjh@cpax.org.uk>
Date2015-04-03 20:55 +0100
Message-ID<mfmr6o$qbj$1@dont-email.me>
In reply to#59540
On 03/04/15 20:23, James Kuyper wrote:
> On 04/03/2015 08:28 AM, jacobnavia wrote:
>> Hi
>>
>> I have written a document about the discusssion that we had in this
>> group. It would be nice to give to newcomers here, so that they can read
>> non-trivial code that is well documented.

<snip>

> You also wrote:
> "Another problem with the base specification is that there is no
> standard function to output numbers with an arbitrary base!"
>
> I'm a little confused by that comment - there is such a function, and
> it's name is strtoll(), and you're implementing it.

A couple of points here. Firstly, I think Jacob Navia regards strtoll() 
as a way to /input/ numeric representations in arbitrary bases - get the 
input via a string, and convert it into an integer type. The 
corresponding output functions would be ltostr, lltostr... which the C 
Standard does not specify. Nor does it provide... okay, with the caveat 
that I haven't read the Standard for at least twenty minutes, but if it 
hasn't changed yet again under my feet, then it does not provide format 
specifiers to allow *printf to write out numeric representations in an 
arbitrary base.

Secondly, I chose my words very carefully in that paragraph. What strtol 
and strtoll read is not numbers with an arbitrary base, but numeric 
representations in an arbitrary base. Numbers do not have bases. A 
number is the same number no matter how you represent it. The following:

****
IV
4
100 (base two)
11 (base three)
10 (base four)
the number of apples you have if you have an apple, another apple, yet 
another apple, and still another apple, but no more apples than that

are all representations of the same number.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#59550

Fromglen herrmannsfeldt <gah@ugcs.caltech.edu>
Date2015-04-03 20:41 +0000
Message-ID<mfmtst$1e0$1@speranza.aioe.org>
In reply to#59544
Richard Heathfield <rjh@cpax.org.uk> wrote:

(snip)

> A couple of points here. Firstly, I think Jacob Navia regards strtoll() 
> as a way to /input/ numeric representations in arbitrary bases - get the 
> input via a string, and convert it into an integer type. The 
> corresponding output functions would be ltostr, lltostr... which the C 
> Standard does not specify. Nor does it provide... okay, with the caveat 
> that I haven't read the Standard for at least twenty minutes, but if it 
> hasn't changed yet again under my feet, then it does not provide format 
> specifiers to allow *printf to write out numeric representations in an 
> arbitrary base.
 
> Secondly, I chose my words very carefully in that paragraph. What strtol 
> and strtoll read is not numbers with an arbitrary base, but numeric 
> representations in an arbitrary base. Numbers do not have bases. A 
> number is the same number no matter how you represent it. The following:

Seems to me that sometimes the distinction is important and sometimes
not so important.

If I say X'3F' is a hexadecimal number, it is pretty obvious, even
though it is the hexadecimal representation of an abstract
mathematical integer value.

But on pi day (March 14th) I wasn't celebrating. It is a strange
connection between the decimal representation of the numerical
value and the unexplainable representation of dates on the
calendar.  (e day is on February 71st.) 

Seems to me that some years ago number bases were taught in 
elementary school as part of "new math", but that has faded.
People are expected to know that computers use binary (even
when they don't) but not actually understand binary, or any
base other than ten.

-- glen

[toc] | [prev] | [next] | [standalone]


#59551

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2015-04-03 13:52 -0700
Message-ID<a8a82f0c-a811-4cbd-bd59-4eb42c58d0c3@googlegroups.com>
In reply to#59550
On Friday, April 3, 2015 at 9:41:12 PM UTC+1, glen herrmannsfeldt wrote:
> 
> Seems to me that some years ago number bases were taught in 
> elementary school as part of "new math", but that has faded.
> People are expected to know that computers use binary (even
> when they don't) but not actually understand binary, or any
> base other than ten.
>
We were taught them as a curiosity. We were told to solve mixed-
base problems by converting to denary, which even at my tender
age I thought wasn't a terribly mathematical strategy. There was
a question in base twelve which used the digits t and e - that
was the only one which adventured beyond base ten.

Now computers have taken over, number bases are core, and children
should be taught to be completely happy with them.



[toc] | [prev] | [next] | [standalone]


#59553

FromRichard Heathfield <rjh@cpax.org.uk>
Date2015-04-03 22:25 +0100
Message-ID<mfn0dv$dh5$1@dont-email.me>
In reply to#59551
On 03/04/15 21:52, Malcolm McLean wrote:
> On Friday, April 3, 2015 at 9:41:12 PM UTC+1, glen herrmannsfeldt wrote:
>>
>> Seems to me that some years ago number bases were taught in
>> elementary school as part of "new math", but that has faded.
>> People are expected to know that computers use binary (even
>> when they don't) but not actually understand binary, or any
>> base other than ten.
>>
> We were taught them as a curiosity. We were told to solve mixed-
> base problems by converting to denary, which even at my tender
> age I thought wasn't a terribly mathematical strategy.

The entire UK population used to be perfectly at home with bases ten, 
twelve, and twenty - and a fair percentage of them with base twenty-one. 
They didn't see anything remotely unusual or difficult about adding up a 
quid nine bob and elevenpence halfpenny, half a crown, and fifteen bob 
threepence three farthings.

One little old lady was overheard (ref: "Eavesdroppings", by Nigel Rees) 
explaining to her friend how to cope with the twenty-four hour clock: "I 
pretend the hours are pennies, I turn them into shillings and pence, and 
then I throw away the shilling." A perfect algorithm.

Decimal currency was a backward step.

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#59567

FromBartc <bc@freeuk.com>
Date2015-04-04 00:17 +0100
Message-ID<mfn702$6gf$1@dont-email.me>
In reply to#59553
On 03/04/2015 22:25, Richard Heathfield wrote:
> On 03/04/15 21:52, Malcolm McLean wrote:
>> On Friday, April 3, 2015 at 9:41:12 PM UTC+1, glen herrmannsfeldt wrote:
>>>
>>> Seems to me that some years ago number bases were taught in
>>> elementary school as part of "new math", but that has faded.
>>> People are expected to know that computers use binary (even
>>> when they don't) but not actually understand binary, or any
>>> base other than ten.
>>>
>> We were taught them as a curiosity. We were told to solve mixed-
>> base problems by converting to denary, which even at my tender
>> age I thought wasn't a terribly mathematical strategy.
>
> The entire UK population used to be perfectly at home with bases ten,
> twelve, and twenty - and a fair percentage of them with base twenty-one.

As well as 3, 8, 14, 16 (feet/yard, pints/gallon, lbs/stone, ounces/lb) 
and probably many others. But it's was more modulo arithmetic rather 
than using bases, as the numbers of each unit are still expressed in 
decimal.

Many of these are mixed 'base' as well, another difference from numbers 
that genuinely use other bases where the base doesn't usually change 2 
or 3 times within the number.

-- 
Bartc

[toc] | [prev] | [next] | [standalone]


#59568

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2015-04-03 16:27 -0700
Message-ID<763f539f-7c37-4b3a-8b2c-53d2d38d64cb@googlegroups.com>
In reply to#59567
On Saturday, April 4, 2015 at 12:17:25 AM UTC+1, Bart wrote:
>
> As well as 3, 8, 14, 16 (feet/yard, pints/gallon, lbs/stone, ounces/lb) 
> and probably many others. But it's was more modulo arithmetic rather 
> than using bases, as the numbers of each unit are still expressed in 
> decimal.
> 
The measures are designed to be useful, rather than be divided up neatly.
So a penny was the amount a working man should receive for a day's
labour (there's been inflation since then). A gallon was the amount
of ale he would consume in a day (men aren't what they used to be
like, either), a pint was the capacity of his tankard, and so on. 

[toc] | [prev] | [next] | [standalone]


#59573

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2015-04-04 02:07 +0100
Message-ID<87iodc1z11.fsf@bsb.me.uk>
In reply to#59553
Richard Heathfield <rjh@cpax.org.uk> writes:

> On 03/04/15 21:52, Malcolm McLean wrote:
>> On Friday, April 3, 2015 at 9:41:12 PM UTC+1, glen herrmannsfeldt wrote:
>>>
>>> Seems to me that some years ago number bases were taught in
>>> elementary school as part of "new math", but that has faded.
>>> People are expected to know that computers use binary (even
>>> when they don't) but not actually understand binary, or any
>>> base other than ten.
>>>
>> We were taught them as a curiosity. We were told to solve mixed-
>> base problems by converting to denary, which even at my tender
>> age I thought wasn't a terribly mathematical strategy.
>
> The entire UK population used to be perfectly at home with bases ten,
> twelve, and twenty

I don't think so.  They were familiar with multiplication and division
by (and with remainders modulo) 12 and 20.  The only number system base
they knew (if they ever knew it as one) was 10.

The old monetary system was not base 12.  So much not base 12 that no
one bothered to invent digits for 10 and 11 -- they were written in
decimal (though they are of course digits none the less) -- and neither
12 shillings nor 12 nor 20 pounds had any monetary significance that I
can recall.  What's more, it was not uncommon to dispense with the
pounds as anyone who's had a point of 80/- will recall.

Counting in groups of X is not the same as using a base X number system,
and I'd go further and argue that using the mixed base system of binary
fractions, dozens of pennies and multiples of twenty shillings actually
got in the way of understanding of the idea of a number base.

(Your remark might of course be a joke, since you made a similar
suggestion about weeks being "base 7," and that turned out to be a
joke.)

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#59581

FromMalcolm McLean <malcolm.mclean5@btinternet.com>
Date2015-04-04 03:44 -0700
Message-ID<9038e4c1-32ba-4da4-a301-7c6e46becb11@googlegroups.com>
In reply to#59573
On Saturday, April 4, 2015 at 2:08:14 AM UTC+1, Ben Bacarisse wrote:
> Richard Heathfield <rjh@cpax.org.uk> writes:
> 
> > The entire UK population used to be perfectly at home with bases ten,
> > twelve, and twenty
> 
> I don't think so.  They were familiar with multiplication and division
> by (and with remainders modulo) 12 and 20.  The only number system base
> they knew (if they ever knew it as one) was 10.
> 
> The old monetary system was not base 12.  So much not base 12 that no
> one bothered to invent digits for 10 and 11 -- they were written in
> decimal (though they are of course digits none the less) -- and neither
> 12 shillings nor 12 nor 20 pounds had any monetary significance that I
> can recall.  What's more, it was not uncommon to dispense with the
> pounds as anyone who's had a point of 80/- will recall.
> 
> Counting in groups of X is not the same as using a base X number system,
> and I'd go further and argue that using the mixed base system of binary
> fractions, dozens of pennies and multiples of twenty shillings actually
> got in the way of understanding of the idea of a number base.
> 
> (Your remark might of course be a joke, since you made a similar
> suggestion about weeks being "base 7," and that turned out to be a
> joke.)
> 
Yes. 
The key is zero, and place value. So you never say "five shillings"
but always five shillings and zero pence". That's contrary to the
way most people speak. Also, zero was rather controversial. 
Latin numerals have a kind of place value, because a lower digit 
before a higher digit means "subtract", but they are too tied
to the concept of tallying to allow the leap - you had to go to
university to learn how do division in the Middle Ages.

[toc] | [prev] | [next] | [standalone]


#59582

FromRichard Heathfield <rjh@cpax.org.uk>
Date2015-04-04 12:13 +0100
Message-ID<mfogv2$j8e$1@dont-email.me>
In reply to#59581
On 04/04/15 11:44, Malcolm McLean wrote:
> On Saturday, April 4, 2015 at 2:08:14 AM UTC+1, Ben Bacarisse wrote:

<snip>
>>
>> (Your remark might of course be a joke, since you made a similar
>> suggestion about weeks being "base 7," and that turned out to be a
>> joke.)

(Such as it was, anyway.)

>>
> Yes.
> The key is zero, and place value. So you never say "five shillings"
> but always five shillings and zero pence".

Um, no. You /wrote/ it, but you didn't say it.

It was written like this: 5/-

So you didn't even write a 0, just a -.

You /said/ "five shillings". Or, if you hadn't been to Harrow and 
Oxford, "five bob".

Actually, I didn't even say that, because five bob was out of my 
financial league. "Sixpence" was about my limit, except at Christmas.

Of course, "sixpence" was the amount. The half-bob /coin/ was called the 
tanner. And the half-tanner coin was the threepenny bit, a twelve-sided 
coin that felt quite substantial to one of my tender years.

Curiously, the threepenny bit is making a comeback in a couple of years, 
re-badged as the pound coin. (I am not joking.)

It will have the traditional twelve sides, and, as near as I can make 
out, it will have approximately the same buying power now as it did 
shortly before it went on holiday in 1971 - i.e. a little bit shy of the 
price of a bag of chips (or "English French fries", as our crosspondian 
cousins have been known to call them).

> That's contrary to the
> way most people speak. Also, zero was rather controversial.

It was so controversial that it became a key campaign issue in the 
November 993 election campaign (also known to historians as Y1K).

> Latin numerals have a kind of place value, because a lower digit
> before a higher digit means "subtract", but they are too tied
> to the concept of tallying to allow the leap - you had to go to
> university to learn how do division in the Middle Ages.

I will make a special point of going to university, then, as I have 
always wanted to learn how to do division in the Middle Ages. :-)

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

[toc] | [prev] | [next] | [standalone]


#59546

FromJames Kuyper <jameskuyper@verizon.net>
Date2015-04-03 16:11 -0400
Message-ID<551EF3E9.3020708@verizon.net>
In reply to#59540
On 04/03/2015 03:23 PM, James Kuyper wrote:
...
> You also wrote:
> "Another problem with the base specification is that there is no
> standard function to output numbers with an arbitrary base!"
> 
> I'm a little confused by that comment - there is such a function, and
> it's name is strtoll(), and you're implementing it.

Forget that part. Richard's response made me realize that I somehow
managed to understand your comment backwards. I've been running low on
sleep lately, so that's probably why.

[toc] | [prev] | [next] | [standalone]


#59552

FromKeith Thompson <kst-u@mib.org>
Date2015-04-03 14:12 -0700
Message-ID<87mw2oyl06.fsf@kst-u.example.com>
In reply to#59540
James Kuyper <jameskuyper@verizon.net> writes:
[...]
> 1. Mandating that an error indication of some kind be returned if any
> other base is requested. This would complicate the code, and (very!)
> marginally slow it down - with no apparent benefit.
[...]

One change I would like to see is to require reporting an error if a
base other than 0 or 2..36 is passed.  N1570 leaves the behavior
undefined.  (glibc returns 0 and sets errno to EINVAL, which is not one
of the standard values defined in 7.5 <errno.h>).

Perhaps the committee didn't bother to define error detection for the
base because the base is usually a constant.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

[toc] | [prev] | [next] | [standalone]


#59561

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2015-04-03 23:56 +0200
Message-ID<mfn294$jfa$1@dont-email.me>
In reply to#59540
Le 03/04/2015 21:23, James Kuyper a écrit :
> You wrote "I’m not really defending the way the strto*() functions are
> designed, but given what they do allowing any integer base 2-36 is
> really only a tiny bit of overdesign compared to allowing only a few
> bases in that range."

If you read carefully I am just quoting R. Wessel. It was him that said 
that. Anyway, it is not so important, I will add your reaction to the 
document.

Further down in your message, you say:

"Another problem with the base specification is that there is no
standard function to output numbers with an arbitrary base!"

I'm a little confused by that comment - there is such a function, and
it's name is strtoll(), and you're implementing it.

Well it is a confusion about what is "input" and "output". For me, 
strtoll input a character string into the computer and translate that 
into a binary number.
lltostr and ulltostr would output a number from the internal binary form 
into an external, character base form.

[toc] | [prev] | [next] | [standalone]


#59541

FromIan Collins <ian-news@hotmail.com>
Date2015-04-04 08:41 +1300
Message-ID<co88ndF37dpU5@mid.individual.net>
In reply to#59511
jacobnavia wrote:
> Hi
>
> I have written a document about the discusssion that we had in this
> group. It would be nice to give to newcomers here, so that they can read
> non-trivial code that is well documented.
>
> There was a wiki project that was started long ago but didn't go further
> because of copyright problems with Mr Plaugher.
>
> Is that  still active? Could I upload the pdf there?
>
> I have written the names of the people that participated in the
> document. Is that OK with you?
>
> The URL is:
>
> http://www.cs.virginia.edu/~lcc-win32/strtoll.pdf

I can send you my test cases if you are interested in including them.

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#59557

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2015-04-03 23:33 +0200
Message-ID<mfn0ug$drm$2@dont-email.me>
In reply to#59541
Le 03/04/2015 21:41, Ian Collins a écrit :
> jacobnavia wrote:
>> Hi
>>
>> I have written a document about the discusssion that we had in this
>> group. It would be nice to give to newcomers here, so that they can read
>> non-trivial code that is well documented.
>>
>> There was a wiki project that was started long ago but didn't go further
>> because of copyright problems with Mr Plaugher.
>>
>> Is that  still active? Could I upload the pdf there?
>>
>> I have written the names of the people that participated in the
>> document. Is that OK with you?
>>
>> The URL is:
>>
>> http://www.cs.virginia.edu/~lcc-win32/strtoll.pdf
>
> I can send you my test cases if you are interested in including them.
>

Yes please. Then I would add a section about test ases, how do you build 
them, etc. That would be nice

[toc] | [prev] | [next] | [standalone]


#59543

FromJames Lothian <james@firstnamelastname.freeserve.co.uk>
Date2015-04-03 20:51 +0100
Message-ID<mfmqu1$nc2$1@dont-email.me>
In reply to#59511
jacobnavia wrote:
> Hi
> 
> I have written a document about the discusssion that we had in this group. It
> would be nice to give to newcomers here, so that they can read non-trivial code
> that is well documented.
> 
> There was a wiki project that was started long ago but didn't go further because
> of copyright problems with Mr Plaugher.
> 
> Is that  still active? Could I upload the pdf there?
> 
> I have written the names of the people that participated in the document. Is
> that OK with you?
> 
> The URL is:
> 
> http://www.cs.virginia.edu/~lcc-win32/strtoll.pdf

4 int Atoi(char *str)
5 {
6 int result=0;
7 int sign = 0;
8
9 while (isspace(*str)) str++;
10 if (*str == ’-’) {
11 sign = 1;
12 str++;
13 }
14 else if (sign == ’+’) sign++;
15 while (*str) {
16 result = result*10 + *str - ’0’;
17 str++;
18 }
19 if (sign) result = -result;
20 return result;
21 }

Erm, at the risk of being picky, shouldn't line 14 be
else if (*str == '+') str ++;
?

James


-- 
---------------------------------------------
demangle my email address in the obvious way.

[toc] | [prev] | [next] | [standalone]


#59545

Fromasetofsymbols@gmail.com
Date2015-04-03 13:09 -0700
Message-ID<8a9be12a-e6c6-4cfe-8187-4e4f9db5a1f0@googlegroups.com>
In reply to#59543
James wrote: <<
4 int Atoi(char *str) 
5 { 
6 int result=0; 
7 int sign = 0; 
8 
9 while (isspace(*str)) str++; 
10 if (*str == '-') { 
11 sign = 1; 
12 str++; 
13 } 
14 else if (sign == '+') sign++; 
15 while (*str) { 
16 result = result*10 + *str - '0'; 
17 str++; 
18 } 
19 if (sign) result = -result; 
20 return result; 
21 } 

Erm, at the risk of being picky, shouldn't line 14 be 
else if (*str == '+') str ++; 
? 

James>>

Yes...possibly
The char ' in '0' is wrong for me

I would modify

while(*str)
 {int k;
 k= *str -'0';
 if(k>9||k<0) break;
 result = result*10 + k; 
 str++; 
 } 

[toc] | [prev] | [next] | [standalone]


Page 1 of 4  [1] 2 3 4  Next page →

Back to top | Article view | comp.lang.c


csiph-web