-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsoleInput.h
More file actions
30 lines (23 loc) · 872 Bytes
/
Copy pathconsoleInput.h
File metadata and controls
30 lines (23 loc) · 872 Bytes
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
//
// Created by krith on 2/5/2026.
//
#ifndef PRACTICECSNIPPETS_CONSOLEINPUT_H
#define PRACTICECSNIPPETS_CONSOLEINPUT_H
// Define a 128-bit signed integer
typedef _BitInt(128) int128;
// Define an unsigned version of the same width
typedef unsigned _BitInt(128) uint128;
// Define MAX safely
// (uint128)-1 gives all 1s. Shifting right by 1 gives the max positive signed value.
#define I128_MAX ((int128)(((uint128)-1) >> 1))
// Define MIN safely
// In two's complement, MIN is just -MAX - 1
#define I128_MIN (-I128_MAX - 1)
bool safe_add_int128(int128* res, int128 a, int128 b);
bool safe_mul_int128(int128* res, int128 a, int128 b);
bool parse_int128(const char* str, int128* result);
int128 scanc();
void print_bitint128(int128 n);
char* bitint128_to_str(_BitInt(128) value);
char* toString(int128* array, int length);
#endif //PRACTICECSNIPPETS_CONSOLEINPUT_H