Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why itoa and atoi?

203 views
Skip to first unread message

Morten Warankov

unread,
May 15, 1998, 3:00:00 AM5/15/98
to

Any,

There are two lisp functions, 'atoi' and 'itoa', I have problems to
explain to new lispers. Not the functionality, but the origin for their
name.

Can anybody explain why they are called 'atoi' and 'itoa' and not 'stoi'
and 'itos'?
Any conflict from other lisp languages, maybe?

Regards,

Mortenw


Stephen Tate

unread,
May 15, 1998, 3:00:00 AM5/15/98
to

A complete guess here (and probably completely wrong!) but I thought it may
have come from the C language. Both atoi & itoa are available in C. In C
there are no strings, instead you have an array of characters (terminated in
a null) .

So, if I had to guess, I would say it's 'array to integer' and 'integer to
array'.

Let me know if you find the real answer!

Stephen Tate

Morten Warankov wrote in message <355C1E53...@abacus.no>...

Owen Wengerd

unread,
May 15, 1998, 3:00:00 AM5/15/98
to

Morten:

Ascii TO Integer, and Integer TO Ascii. :)
--
Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com



Morten Warankov wrote in message <355C1E53...@abacus.no>...

>[...]


>Can anybody explain why they are called 'atoi' and 'itoa' and not 'stoi'
>and 'itos'?
>Any conflict from other lisp languages, maybe?

>[...]

Darren J. Young

unread,
May 15, 1998, 3:00:00 AM5/15/98
to

[This followup was posted to autodesk.autocad.customization and a copy
was sent to the cited author.]

In article <355C1E53...@abacus.no>, mor...@abacus.no says...


> There are two lisp functions, 'atoi' and 'itoa', I have problems to
> explain to new lispers. Not the functionality, but the origin for their
> name.
>

> Can anybody explain why they are called 'atoi' and 'itoa' and not 'stoi'
> and 'itos'?
> Any conflict from other lisp languages, maybe?

Don't know it it's legitimate or not but it does help you remember their
meaning by thinking of them as...

ATOI = Ascii TO Integer

-and-

ITOA = Integer TO Ascii

Sincerely,
--
Y-------------------------------------------------------------------+
| Darren J. Young | Minnesota CADWorks, Inc. |
| dyo...@mcwi.com | P.O. Box 7293 |
| ftp://ftp.mcwi.com | St. Cloud, Minnesota 56302-7293 |
| http://www.mcwi.com | Phone: 1-320-654-9053 |
| CAD/CAM/CNC - Drafting Design Customization Training Programming |
0,0-----------------------------------------------------------------X
Email addresses not to be sold or used for unsolicited advertisements

No responses will be made to users with altered Email addresses
intended to block SPAM. It takes longer to edit them than hit delete!

Pierre Cardinal

unread,
May 15, 1998, 3:00:00 AM5/15/98
to

My best guess is "Alpha-numeric" to "Integer" and vice-versa.

Pierre.

:-)

Morten Warankov wrote in message <355C1E53...@abacus.no>...

>Any,


>
>There are two lisp functions, 'atoi' and 'itoa', I have problems to
>explain to new lispers. Not the functionality, but the origin for their
>name.
>
>Can anybody explain why they are called 'atoi' and 'itoa' and not 'stoi'
>and 'itos'?
>Any conflict from other lisp languages, maybe?
>

>Regards,
>
>Mortenw
>
>
>

Ian A. White

unread,
May 15, 1998, 3:00:00 AM5/15/98
to

On Fri, 15 May 1998 12:46:54 +0100, "Stephen Tate"
<Stephe...@dial.pipex.com> wrote:

>A complete guess here (and probably completely wrong!) but I thought it may
>have come from the C language. Both atoi & itoa are available in C. In C
>there are no strings, instead you have an array of characters (terminated in
>a null) .
>
>So, if I had to guess, I would say it's 'array to integer' and 'integer to
>array'.

The functions atoi and itoa stand for ASCII to Integer, and Integer to
ASCII respectively.


--

Regards,

Ian A. White, CPEng
WAI Engineering
Sydney 2000
Australia

Ph: +61 418 203 229
Fax: +61 2 9622 0450

Junk e-mail will be returned, as is, to the sender's host system.

Clifford Middleton

unread,
May 15, 1998, 3:00:00 AM5/15/98
to

Aren't ASCII chars all integers. That's why the (ascii <string>)
function always returns an integer.

I vote for alpha to integer and integer to alpha.

Jon Fleming

unread,
May 15, 1998, 3:00:00 AM5/15/98
to

All the many ways of representing characters in computers use integers.
ASCII (American Standard Code for Information Interchange) is a system by
which characters are assigned integer codes. "itoa" accepts an integer
(stored as a binary number), and calculates the ASCII codes for the
characters that make up the decimal representation of that integer. An
"integer to alpha" function could return its result in EBCDIC (Extended
Binary Coded Decimal InterChange, I think), Unicode, card punch codes, or
any of several other coding schemes. Since itoa produces ASCII, I vote tor
"Integer TO Ascii".

jrf

Matt Dillon

unread,
May 16, 1998, 3:00:00 AM5/16/98
to

I vote we fergit the whole thing and have a beer. <G>

On Fri, 15 May 1998 21:06:07 EDT, Jon Fleming <jo...@fleming-group.com>
wrote:

Matt Dillon
The D.C. CADD Company, Inc.
(Remove nospam for email reply)

Clifford Middleton

unread,
May 16, 1998, 3:00:00 AM5/16/98
to

I am taking your advice right now, Matt and converting my alphas to ints
while the rest of the world converts asciis to ints. I hope whoever
wrote that subr can tell us the secret. It's extremely important to the
whole programming community.

Ian A. White

unread,
May 16, 1998, 3:00:00 AM5/16/98
to

On Fri, 15 May 1998 20:04:41 -0400, Clifford Middleton
<mid...@tc3net.com> wrote:

>Aren't ASCII chars all integers. That's why the (ascii <string>)
>function always returns an integer.
>
>I vote for alpha to integer and integer to alpha.

But itoa will display more than just the alphabetic character. It
displays the representation of the ASCII character.

Ben Sauvin

unread,
May 16, 1998, 3:00:00 AM5/16/98
to

Dunno about the "whole programming community". I've been programming in C off
and on for a very long time, and pondered the same thing for the functionally
equivalent and identically named functions itoa() and atoi() included with the
standard libraries. I drew the same conclusion: AlphaTOInteger and IntegerTOAscii.

These functions have been around since before the PDP-11, I believe.


Clifford Middleton wrote:

> I am taking your advice right now, Matt and converting my alphas to ints
> while the rest of the world converts asciis to ints. I hope whoever
> wrote that subr can tell us the secret. It's extremely important to the
> whole programming community.
>
> Matt Dillon wrote:
> >
> > I vote we fergit the whole thing and have a beer. <G>
> >
> > On Fri, 15 May 1998 21:06:07 EDT, Jon Fleming <jo...@fleming-group.com>
> > wrote:
> >
> > >All the many ways of representing characters in computers use integers.
> > >ASCII (American Standard Code for Information Interchange) is a system by
> > >which characters are assigned integer codes. "itoa" accepts an integer
> > >(stored as a binary number), and calculates the ASCII codes for the
> > >characters that make up the decimal representation of that integer. An
> > >"integer to alpha" function could return its result in EBCDIC (Extended
> > >Binary Coded Decimal InterChange, I think), Unicode, card punch codes, or
> > >any of several other coding schemes. Since itoa produces ASCII, I vote tor
> > >"Integer TO Ascii".
> > >
> > >jrf
> > >

> > >In article <355CD819...@tc3net.com>, Clifford Middleton wrote:
> > >> Aren't ASCII chars all integers. That's why the (ascii <string>)
> > >> function always returns an integer.
> > >>
> > >> I vote for alpha to integer and integer to alpha.
> > >>

Clifford Middleton

unread,
May 16, 1998, 3:00:00 AM5/16/98
to

itoa doesn't display anything. It converts an integer to a string.

Ian A. White wrote:
>
> On Fri, 15 May 1998 20:04:41 -0400, Clifford Middleton

> <mid...@tc3net.com> wrote:
>
> >Aren't ASCII chars all integers. That's why the (ascii <string>)
> >function always returns an integer.
> >
> >I vote for alpha to integer and integer to alpha.
>

Morten Warankov

unread,
May 18, 1998, 3:00:00 AM5/18/98
to waiw...@zip.com.au


Ian A. White wrote:

> The functions atoi and itoa stand for ASCII to Integer, and Integer to
> ASCII respectively.
>

Any,
Purely academic discussion following.
If you prefer to have a beer and vote for what your application is doing; do so!
(G)


Ian,
That IS my guess as well, but I wondered if someone had an insight of how this
'inconsistency' started. If you search the net you'll find that due to this
'inconsistency', people are writing their own codes for built-in functions, and I
thought with some further details of how these functions were created, some of
these vasted-time programming hours could have been eliminated.

My 'guess explanation' is that functions converting the TYPE of input and the
input is kept, are called ?to?, whilst functions converting the INPUT (may /may
not be into a different format) have any other naming convention:

itoa, atoi, atof, rtos, distof, etc are all returning the same input in a
different format.
chr, ascii, cvunit, etc... are returning a different value, some in the same
format others in a different format.

If this really makes sense, this settles a naming convention for our own
functions as well as an easier way to search for conversion functions.

Regards,

Mortenw


Morten Warankov

unread,
May 18, 1998, 3:00:00 AM5/18/98
to

Matt Dillon wrote:

> I vote we fergit the whole thing and have a beer. <G>
>

Fully agree. Go out and have a beer and vote for what your application is doing.
(G)

Mortenw


Yvon Bourgouin

unread,
May 26, 1998, 3:00:00 AM5/26/98
to

My guess is ASCII to Integer and Integer to ASCII
Yvon

Pierre Cardinal a écrit:

> My best guess is "Alpha-numeric" to "Integer" and vice-versa.
>
> Pierre.
>
> :-)
>
> Morten Warankov wrote in message <355C1E53...@abacus.no>...

0 new messages