From: | jian he <jian(dot)universality(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | 128-bit integers can range only up to (2 ^ 63 -1) |
Date: | 2023-01-03 10:27:10 |
Message-ID: | CACJufxHeGQ=LPbzDAdiK1XdTkjzbgRfsYSrOzCXNyK8vkT6qwA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
include/pg_config.h
14: #define ALIGNOF_PG_INT128_TYPE 16
355: #define MAXIMUM_ALIGNOF 8
374: #define PG_INT128_TYPE __int128
/include/c.h
507: /*
508: * 128-bit signed and unsigned integers
509: * There currently is only limited support for such types.
510: * E.g. 128bit literals and snprintf are not supported; but math is.
511: * Also, because we exclude such types when choosing MAXIMUM_ALIGNOF,
512: * it must be possible to coerce the compiler to allocate them on no
513: * more than MAXALIGN boundaries.
514: */
515: #if defined(PG_INT128_TYPE)
516: #if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <=
MAXIMUM_ALIGNOF
517: #define HAVE_INT128 1
518:
519: typedef PG_INT128_TYPE int128
520: #if defined(pg_attribute_aligned)
521: pg_attribute_aligned(MAXIMUM_ALIGNOF)
522: #endif
523: ;
524:
525: typedef unsigned PG_INT128_TYPE uint128
526: #if defined(pg_attribute_aligned)
527: pg_attribute_aligned(MAXIMUM_ALIGNOF)
528: #endif
529: ;
530:
531: #endif
532: #endif
533:
Hi.
I am slightly confused by the int128 type. I thought the 128 bit integer
means range type will be upto 2 ^ 127 - 1.
Now just copy the above code and test the int128 range.
int128 can only up to 9223372036854775807 (2 ^ 63 -1).
also
File: /home/jian/helloc/pg/pg_interval/include/pg_config_ext.h
6: /* Define to the name of a signed 64-bit integer type. */
7: #define PG_INT64_TYPE long int
I also thought that 64-bit means range up to 2 ^ 63 -1. Obviously I was
wrong.
So when we say "128 bit" what does it actually mean?
--
I recommend David Deutsch's <<The Beginning of Infinity>>
Jian
From | Date | Subject | |
---|---|---|---|
Next Message | vignesh C | 2023-01-03 10:31:29 | Re: TAP output format in pg_regress |
Previous Message | Bharath Rupireddy | 2023-01-03 09:52:37 | Re: Simplify standby state machine a bit in WaitForWALToBecomeAvailable() |