KCC - Kayte C Compiler
1.10.0
A C compiler implementation with preprocessor, lexer, parser, and code generator
Loading...
Searching...
No Matches
macros
math.h
1
//
2
// Created by Pedro Dias Vicente on 03/09/2025.
3
//
4
/*
5
* simple_math.h - A simplified, educational example of what the
6
* C standard math header (math.h) might look like.
7
*
8
* This file demonstrates function prototypes and macros for common
9
* mathematical operations.
10
*/
11
12
// =============================================================================
13
// 1. Header Guard
14
// =============================================================================
15
#ifndef MATH_H
16
#define MATH_H
17
18
// =============================================================================
19
// 2. Macro Definitions for Mathematical Constants
20
// =============================================================================
21
#define M_PI 3.14159265358979323846
// Pi
22
#define M_E 2.71828182845904523536
// Euler's number
23
#define M_SQRT2 1.41421356237309504880
// Square root of 2
24
25
// =============================================================================
26
// 3. Function Prototypes (Declarations)
27
// =============================================================================
28
// These functions typically operate on 'double' precision floating-point numbers.
29
// The actual implementations are in the C standard library.
30
31
// --- Trigonometric Functions ---
32
// Note: These functions usually take angles in radians.
33
double
sin(
double
x);
// Sine of x
34
double
cos(
double
x);
// Cosine of x
35
double
tan(
double
x);
// Tangent of x
36
37
// --- Inverse Trigonometric Functions ---
38
double
asin(
double
x);
// Arc sine of x
39
double
acos(
double
x);
// Arc cosine of x
40
double
atan(
double
x);
// Arc tangent of x
41
42
// --- Hyperbolic Functions ---
43
double
sinh(
double
x);
// Hyperbolic sine of x
44
double
cosh(
double
x);
// Hyperbolic cosine of x
45
double
tanh(
double
x);
// Hyperbolic tangent of x
46
47
// --- Exponential and Logarithmic Functions ---
48
double
exp(
double
x);
// Returns e raised to the power of x
49
double
log(
double
x);
// Natural logarithm (base e)
50
double
log10(
double
x);
// Common logarithm (base 10)
51
52
// --- Power Functions ---
53
double
pow(
double
base,
double
exponent);
// base raised to the power of exponent
54
double
sqrt(
double
x);
// Square root of x
55
56
// --- Rounding and Remainder Functions ---
57
double
ceil(
double
x);
// Smallest integer value not less than x
58
double
floor(
double
x);
// Largest integer value not greater than x
59
double
fabs(
double
x);
// Absolute value of x
60
double
fmod(
double
x,
double
y);
// Floating-point remainder of x/y
61
62
int
sum(
int
a,
int
b);
63
int
div(
int
a,
int
b);
64
int
mod(
int
a,
int
b);
65
int
abs(
int
a);
66
int
min(
int
a,
int
b);
67
int
max(
int
a,
int
b);
68
69
#endif
// End of header guard MATH_H
Generated by
1.14.0