delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/07/19/04:16:35

From: root AT jacob DOT remcomp DOT fr (root)
Subject: Re: FW: Missing strtoull()...: long long standard
19 Jul 1998 04:16:35 -0700 :
Message-ID: <m0yxpXX-0002fdC.cygnus.gnu-win32@jacob.remcomp.fr>
References: <35AF1517 DOT A5C180B6 AT dgs DOT monash DOT edu DOT au>
To: brendan AT dgs DOT monash DOT edu DOT au (Brendan Simon)
Cc: gnu-win32 AT cygnus DOT com

> 
> My guess is that long long & unsigned long long are not part of the ANSI C
> standard.  GCC is the only compiler I've seen that supports that syntax so
> I assume its a GCC extension to the C language to get 64 bits.
> It would be nice to get a standard 64 bit type.  Does any one know if this
> exists or if one has been proposed ?
> 
> Brendan Simon.
> 
> 

Yes, a standard exists, albeit it is not the official standard yet.
The ANSI C next standard is being discussed as the document:
 WG14/NT794 j11/97-158.

This document proposes long long as a type for the C language page 38.
lcc-win32 has implemented this type too as a long long, with an (automatic)
#define  __int64 long long
to remain Microsoft compatible.

As to strtoll, my system uses atoll, what should be equivalent...
It is not that complicated actually...

Here it is:
----------------------------------------------------- strtoll.c-----------
long long _strtoll(char *str)
{
        long long result = 0;
        int negative=0;

        while (*str == ' ' || *str == '\t')
                str++;
        if (*str == '+')
                str++;
        else if (*str == '-') {
                negative = 1;
                str++;
        }

        while (*str >= '0' && *str <= '9') {
                result = (result*10)+(*str++ - '0');
        }
        return negative ? -result : result;
}

-----------------------------------------------------end of strtoll.c

Unsigned versions are not that complicated either. I leave that as an exercise
to the reader :-)

-- 
Jacob Navia	Logiciels/Informatique
41 rue Maurice Ravel			Tel 01 48.23.51.44
93430 Villetaneuse 			Fax 01 48.23.95.39
France
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019