Topic: New Integer Types (Proposed)


Author: "Steven B. Tuttle" <steven.b.tuttle@gmail.com>
Date: Sun, 26 Dec 2010 10:26:17 CST
Raw View
I have been working with Integer values the last couple of days while
righting a program
that goes throw several billion loops and I need to count the number
times the program goes
throw the loops
needless to say the current long integer  can not keep up the count
so there for if we use a new type specifier for the old type specifier
and add more specafiers
This is my proposed scheme


all specifiers will begin with  "int" and have a number with it
the number will represent 2 to the power of in bytes that the integer
is made up from
such as int0 will be made up of one byte    ( 2 to the power of 0 )
            int1 will be made up of two bytes    ( 2 to the power of
1 )
            int2 will be made up of four bytes    ( 2 to the power of
2 )
            int3 will be made up of eight bytes    (2 to the power of
3 )
and a future integer int4 will be made up of 16 bytes


this table shows the old type specifier and the new type specifier and
approximate rainge

Old Type Specifier    New Type Specifier(Proposed)    Number of
bytes    Number of bits    Range

--none--
int0
1                  8                 +-127
--none--              int0
unsigned                                         1
8                 0 to 255
int
int1
2                  16                +-32 * 1024
int unsigned          int1
unsigned                                       2
16                0 to 64 * 1024
long int
int2
4                  32                +-2 * 1024^3
long int unsigned     int2
unsigned                                     4
32                0 to 4 * 1024^3
--none--
int3
8                  64                +-8 * 1024^6
--none--              int3
unsigned                                         8
64                0 to 16 * 1024^6
Future integer types
--none--
int4
16                 128               +-127 * 1024^12
--none--
int4
16                 128               0 to 256 * 1024^12


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Michael Kilburn <crusader.mike@gmail.com>
Date: Tue, 28 Dec 2010 16:34:26 CST
Raw View
On Dec 26, 10:26 am, "Steven B. Tuttle" <steven.b.tut...@gmail.com>
wrote:
> This is my proposed scheme
>
> all specifiers will begin with  "int" and have a number with it
> the number will represent 2 to the power of in bytes that the integer
> is made up from
> such as int0 will be made up of one byte    ( 2 to the power of 0 )


Good idea! But a bit old :-)

int_types.h:

#if defined(__GNUC__)

#   if defined(__linux)
#       include <stdint.h>
#   elif defined(__sun)
#       include <inttypes.h>
#   else
#       error Not implemented
#   endif

#elif defined(_MSC_VER)
typedef __int8  int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8  uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
// [but seems to be not the same as char/short/int when used with
templates]

#else
#error Please adjust int_types.h for your compiler!

#endif


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: John G Harris <news0@nospam.demon.co.uk>
Date: Tue, 28 Dec 2010 16:36:32 CST
Raw View
On Sun, 26 Dec 2010 at 10:26:17, in comp.std.c++, Steven B. Tuttle
wrote:

   <snip>
>all specifiers will begin with  "int" and have a number with it
>the number will represent 2 to the power of in bytes that the integer
>is made up from
>such as int0 will be made up of one byte    ( 2 to the power of 0 )
   <snip>

Remember that 'byte' means sizeof char in the standard, by definition.
E.g 32 bits.

Did you really mean 'octet' (8 bits)?

   John
--
John Harris


[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Sven Eden <clcppm-poster@this.is.invalid>
Date: Wed, 29 Dec 2010 16:28:16 CST
Raw View
Michael Kilburn wrote:

> On Dec 26, 10:26 am, "Steven B. Tuttle" <steven.b.tut...@gmail.com>
> wrote:
>> This is my proposed scheme
> Good idea! But a bit old :-)
> int_types.h:

As stdint.h is not shipped with older C++ compilers and Visual Studio C++
products prior to Visual Studio 2010, they can be fetched here:
   http://code.google.com/p/msinttypes/downloads/list

--
Regards,
Sven Eden
Replies may be sent to sven dot eden at gmx dot de


[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]