Adding the start of math
This commit is contained in:
parent
93f734f5e9
commit
3ac78b4c7f
13 changed files with 628 additions and 0 deletions
34
math/includes/ft_math.h
Normal file
34
math/includes/ft_math.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_math.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/04 12:16:08 by rparodi #+# #+# */
|
||||
/* Updated: 2024/05/28 15:43:40 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef FT_MATH_H
|
||||
# define FT_MATH_H
|
||||
|
||||
# include <unistd.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h>
|
||||
# include "./types.h"
|
||||
|
||||
typedef struct s_number
|
||||
{
|
||||
t_str number;
|
||||
t_str int_part;
|
||||
t_str float_part;
|
||||
t_usize int_size;
|
||||
t_usize float_size;
|
||||
} t_number;
|
||||
|
||||
t_error ft_nblen(const t_str str, t_usize *interger, t_usize *floating);
|
||||
t_error ft_init_numbers(t_str str, t_number *nb);
|
||||
char **ft_split(char const *s, char c);
|
||||
|
||||
#endif
|
||||
76
math/includes/types.h
Normal file
76
math/includes/types.h
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* types.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/03 14:31:12 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/05/24 14:45:04 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#ifdef _FORTIFY_SOURCE
|
||||
# undef _FORTIFY_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/// @brief A string, null terminated
|
||||
typedef char *t_str;
|
||||
/// @brief A constant string, null terminated
|
||||
typedef const char *t_const_str;
|
||||
|
||||
/// @brief an unsigned 8 bit integer
|
||||
typedef uint8_t t_u8;
|
||||
/// @brief a signed 8 bit integer
|
||||
typedef int8_t t_i8;
|
||||
/// @brief an unsigned 16 bit integer
|
||||
typedef uint16_t t_u16;
|
||||
/// @brief a signed 16 bit integer
|
||||
typedef int16_t t_i16;
|
||||
/// @brief an unsigned 32 bit integer
|
||||
typedef uint32_t t_u32;
|
||||
/// @brief a signed 32 bit integer
|
||||
typedef int32_t t_i32;
|
||||
/// @brief an unsigned 64 bit integer
|
||||
typedef uint64_t t_u64;
|
||||
/// @brief a signed 64 bit integer
|
||||
typedef int64_t t_i64;
|
||||
/// @brief a signed integer that can hold a pointer
|
||||
typedef ssize_t t_isize;
|
||||
/// @brief an unsigned integer that can hold a pointer
|
||||
typedef size_t t_usize;
|
||||
|
||||
/// @brief a 32 bit floating point number
|
||||
typedef float t_f32;
|
||||
/// @brief a 64 bit floating point number
|
||||
typedef double t_f64;
|
||||
|
||||
/// @brief a boolean value that represents an error
|
||||
/// @note true is an error, false is no error
|
||||
typedef bool t_error;
|
||||
|
||||
/// @brief a function that denotes an abrupt end of the program
|
||||
/// @param msg the message to print before exiting
|
||||
void me_abort(t_str msg);
|
||||
|
||||
/// @brief a function that denotes a normal end of the program
|
||||
/// @param code the exit code
|
||||
void me_exit(t_i32 code);
|
||||
|
||||
/// @brief a function that prints the current stack trace
|
||||
void print_trace(void);
|
||||
|
||||
/// @def signal that an error occured
|
||||
#define ERROR 1
|
||||
|
||||
/// @def signal that no error occured
|
||||
#define NO_ERROR 0
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue