diff options
author | Mattias Andrée <maandree@kth.se> | 2018-11-16 19:05:17 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2018-11-16 19:05:17 +0100 |
commit | 2a167c84d3a2b875cc67a169b5f0e1333b0b77f5 (patch) | |
tree | 9989fa84311b180f8637c4acdc11e4ff10d44a93 | |
parent | memalloc/arrayalloc: add L1-cache optimisation (diff) | |
download | libsimple-2a167c84d3a2b875cc67a169b5f0e1333b0b77f5.tar.gz libsimple-2a167c84d3a2b875cc67a169b5f0e1333b0b77f5.tar.bz2 libsimple-2a167c84d3a2b875cc67a169b5f0e1333b0b77f5.tar.xz |
Add TWOS_COMPLEMENT, ONES_COMPLEMENT, and SIGN_MAGNITUDE
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libsimple/definitions.h | 27 | ||||
-rw-r--r-- | man0/libsimple-arg.h.0 | 2 | ||||
-rw-r--r-- | man0/libsimple.h.0 | 15 |
3 files changed, 42 insertions, 2 deletions
diff --git a/libsimple/definitions.h b/libsimple/definitions.h index 0ff2677..67825f5 100644 --- a/libsimple/definitions.h +++ b/libsimple/definitions.h @@ -108,6 +108,33 @@ #endif +#if -1 ^ 1 == -2 +/** + * Defined if two's complement is used + * for signed number representation + */ +# ifndef TWOS_COMPLEMENT +# define TWOS_COMPLEMENT +# endif +#elif -1 << 1 == 2 +/** + * Defined if sign–magnitude is used + * for signed number representation + */ +# ifndef SIGN_MAGNITUDE +# define SIGN_MAGNITUDE +# endif +#else +/** + * Defined if ones' complement is used + * for signed number representation + */ +# ifndef ONES_COMPLEMENT +# define ONES_COMPLEMENT +# endif +#endif + + /** * Get the smallest of two numerical values * diff --git a/man0/libsimple-arg.h.0 b/man0/libsimple-arg.h.0 index 550eddd..d60e59e 100644 --- a/man0/libsimple-arg.h.0 +++ b/man0/libsimple-arg.h.0 @@ -1,4 +1,4 @@ -.TH LIBSIMPLE\-ARG.H 0 2018-11-08 libsimple +.TH LIBSIMPLE\-ARG.H 0 2018-11-15 libsimple .SH NAME libsimple\-arg.h \- command line argument parsing header for libsimple .SH SYNOPSIS diff --git a/man0/libsimple.h.0 b/man0/libsimple.h.0 index b912400..47ca55b 100644 --- a/man0/libsimple.h.0 +++ b/man0/libsimple.h.0 @@ -1,4 +1,4 @@ -.TH LIBSIMPLE.H 0 2018-11-07 libsimple +.TH LIBSIMPLE.H 0 2018-11-16 libsimple .SH NAME libsimple.h \- main header for libsimple .SH SYNOPSIS @@ -81,6 +81,19 @@ unless the system defines .PP The header .I <libsimple.h> +also defines, without a value, +.B TWOS_COMPLEMENT +if two's complement is used to represent signed integers, +.B ONES_COMPLEMENT +if ones' complement is used to represent signed integers, or +.B SIGN_MAGNITUDE +if sign\-magnitude is used to represent signed integers. Since +no other representation is permitted in C, the header +.I <libsimple.h> +will define exactly one of these macros. +.PP +The header +.I <libsimple.h> defines a number of functions, macros, and variables. The following macros are defined only without namespacing: |