📄 aritmetic.txt
字号:
/*
* GPL
*
* Written by Diogo Sousa aka orium
* Copyright (C) 2008 Diogo Sousa
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef BIGINTS_H_
#define BIGINTS_H_
#include <stdint.h>
#include <stdbool.h>
/* For best performace double_digit should be the size of one word
* and digit should be halve word
*/
typedef uint32_t double_digit;
typedef int32_t double_digit_signed;
typedef uint16_t digit;
typedef int32_t carry_t;
/* RADIX must be even
* STRING_RADIX must not exceed RADIX
* STRING_RADIX must not exceed 16
* INT_END must be greater (or equal) than RADIX
* RADIX must be greater than 16
*/
#define RADIX ((int32_t)((digit)~0)-1)
#define INT_END ((digit)~0)
#define STRING_RADIX 10
#if STRING_RADIX > 16
#error STRING_RADIX must not exceed 16
#endif
struct integer_str
{
digit *n; /* least significant digit first */
size_t size;
bool negative;
char *string; /* if non-NULL it is not dirty */
};
typedef struct integer_str * integer;
extern integer int_init(integer *);
extern void int_free(integer);
extern integer int_set(integer, integer);
extern integer int_set_int(integer, int);
extern integer int_set_string(integer, char *);
extern char *int_value(integer);
extern int int_cmp(integer, integer);
extern integer int_add(integer, integer, integer);
extern integer int_sub(integer, integer, integer);
extern integer int_mul(integer, integer, integer);
extern integer int_div(integer, integer, integer);
extern integer int_mod(integer, integer, integer);
extern integer int_pow(integer, integer, integer);
extern integer int_abs(integer);
extern integer int_inc(integer);
extern integer int_dec(integer);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -