Hash :
865d1524
Author :
Thomas de Grivel
Date :
2022-10-31T00:50:45
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
/* c3
* Copyright 2022 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted
* the above copyright notice and this permission paragraph
* are included in all copies and substantial portions of this
* software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
/**' ,
* @file integer.h
* @brief Integer manipulation functions.
*
* Structure to manipulate byte strings.
*/
#ifndef INTEGER_H
#define INTEGER_H
#include <stdarg.h>
#include <stdio.h>
#include "hash.h"
#include "types.h"
#define MP_IS_ZERO(a) ((a)->used == 0)
/* Stack allocation compatible functions */
s_integer * integer_init (s_integer *i);
s_integer * integer_init_1 (s_integer *i, const s8 *p);
s_integer * integer_init_zero (s_integer *i);
void integer_clean (s_integer *i);
/* Modifiers */
s_integer * integer_abs (const s_integer *a, s_integer *dest);
s_integer * integer_add (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_band (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_bnot (const s_integer *a, s_integer *dest);
s_integer * integer_bor (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_bxor (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_copy (const s_integer *a, s_integer *dest);
s_integer * integer_div (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_gcd (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_lcm (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_lshift (s_integer *a, sw b, s_integer *dest);
s_integer * integer_mod (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_mul (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_neg (const s_integer *a, s_integer *dest);
s_integer * integer_pow (const s_integer *a, const s_integer *b,
s_integer *dest);
s_integer * integer_sqrt (const s_integer *a, s_integer *dest);
s_integer * integer_sub (const s_integer *a, const s_integer *b,
s_integer *dest);
/* Constructors, call integer_delete after use. */
s_integer * integer_new ();
s_integer * integer_new_copy (const s_integer *a);
/* Observers */
uw integer_bits (const s_integer *i);
uw integer_bytes (const s_integer *i);
s8 integer_compare (const s_integer *a,
const s_integer *b);
s8 integer_compare_s64 (const s_integer *a, s64 b);
s8 integer_compare_u64 (const s_integer *a, u64 b);
t_hash_context * integer_hash_update (t_hash_context *context,
const s_integer *i);
e_bool integer_is_negative (const s_integer *i);
e_bool integer_is_zero (const s_integer *i);
s8 integer_to_s8 (const s_integer *i);
s16 integer_to_s16 (const s_integer *i);
s32 integer_to_s32 (const s_integer *i);
s64 integer_to_s64 (const s_integer *i);
u8 integer_to_u8 (const s_integer *i);
u16 integer_to_u16 (const s_integer *i);
u32 integer_to_u32 (const s_integer *i);
u64 integer_to_u64 (const s_integer *i);
#endif /* INTEGER_H */