-
Notifications
You must be signed in to change notification settings - Fork 0
/
SI.h
71 lines (58 loc) · 1.21 KB
/
SI.h
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
// SI.h - Main header file
// Copyright (c) 2021-2024 Ercan Ersoy
// This file is written by Ercan Ersoy.
// This file is licensed under MIT License.
#ifndef SI_H
#define SI_H
// Include header files
#include <stdint.h>
// Define prefixes
// Define lower prefix type
typedef enum lower_prefixes
{
SI_lower_none = 0,
SI_d = 1,
SI_c = 2,
SI_m = 3,
SI_mc = 6,
SI_n = 9,
SI_p = 12,
SI_f = 15,
SI_a = 18,
SI_z = 21,
SI_y = 24
} SI_lower_prefix;
// Define upper prefix type
typedef enum upper_prefixes
{
SI_upper_none = 0,
SI_da = 1,
SI_h = 2,
SI_k = 3,
SI_M = 6,
SI_G = 9,
SI_T = 12,
SI_P = 15,
SI_E = 18,
SI_Z = 21,
SI_Y = 24
} SI_upper_prefix;
// Define units
// Define lower unit
typedef struct lower
{
long double size;
SI_lower_prefix prefix;
} SI_lower;
// Define upper unit
typedef struct upper
{
long double size;
SI_upper_prefix prefix;
} SI_upper;
// Define function prototypes
// Convert lower function
SI_lower SI_convert_lower(long double, SI_lower_prefix);
// Convert upper function
SI_upper SI_convert_upper(long double, SI_upper_prefix);
#endif