removed the math module (rip)
This commit is contained in:
parent
398dd520d0
commit
50de5a9f80
14 changed files with 0 additions and 729 deletions
131
math/Makefile
131
math/Makefile
|
|
@ -1,131 +0,0 @@
|
||||||
# **************************************************************************** #
|
|
||||||
# #
|
|
||||||
# ::: :::::::: #
|
|
||||||
# Makefile :+: :+: :+: #
|
|
||||||
# +:+ +:+ +:+ #
|
|
||||||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
|
||||||
# +#+#+#+#+#+ +#+ #
|
|
||||||
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
|
|
||||||
# Updated: 2024/05/29 15:37:40 by rparodi ### ########.fr #
|
|
||||||
# #
|
|
||||||
# **************************************************************************** #
|
|
||||||
|
|
||||||
|
|
||||||
# Variables
|
|
||||||
|
|
||||||
# Name
|
|
||||||
NAME = test
|
|
||||||
LIBDIRNAME = libft
|
|
||||||
SRCDIRNAME = sources
|
|
||||||
|
|
||||||
# Commands
|
|
||||||
CC = cc
|
|
||||||
RM = rm -rf
|
|
||||||
|
|
||||||
# Flags
|
|
||||||
CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD
|
|
||||||
|
|
||||||
# Sources
|
|
||||||
LIB =
|
|
||||||
|
|
||||||
SRC = ./main.c \
|
|
||||||
./sources/operation/ft_pow.c \
|
|
||||||
./sources/operation/ft_add.c \
|
|
||||||
./sources/utils/ft_init_numbers.c \
|
|
||||||
./sources/utils/ft_nblen.c \
|
|
||||||
./sources/comparison/ft_is_less.c \
|
|
||||||
./sources/comparison/ft_equal.c \
|
|
||||||
./sources/comparison/ft_is_greater.c \
|
|
||||||
./sources/ft_split.c
|
|
||||||
|
|
||||||
# Objects
|
|
||||||
OBJDIRNAME = ./objects
|
|
||||||
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o))
|
|
||||||
LIB_OBJ = $(addprefix $(OBJDIRNAME)/,$(LIB:.c=.o))
|
|
||||||
|
|
||||||
# Colors
|
|
||||||
GREEN = \033[32m
|
|
||||||
GREY = \033[0;90m
|
|
||||||
RED = \033[0;31m
|
|
||||||
GOLD = \033[38;5;220m
|
|
||||||
END = \033[0m
|
|
||||||
|
|
||||||
# Rules
|
|
||||||
|
|
||||||
# All (make all)
|
|
||||||
all: header $(NAME) footer
|
|
||||||
|
|
||||||
# Bonus (make bonus)
|
|
||||||
bonus: header $(OBJ) $(LIB_OBJ) footer
|
|
||||||
@mkdir -p $(OBJDIRNAME)
|
|
||||||
@mkdir -p $(OBJDIRNAME)/$(LIBDIRNAME)
|
|
||||||
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
|
||||||
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
|
||||||
@printf '$(GREY) Be Carefull ur in $(END)$(GREEN)Debug Mode$(END)\n'
|
|
||||||
@cc $(CFLAGS) -D DEBUG=42 -o $(NAME) $(OBJ) $(LIB_OBJ)
|
|
||||||
|
|
||||||
# Clean (make clean)
|
|
||||||
clean:
|
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n'
|
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n'
|
|
||||||
@$(RM) $(OBJDIRNAME)
|
|
||||||
|
|
||||||
# Clean (make fclean)
|
|
||||||
fclean: clean
|
|
||||||
@printf '$(GREY) Removing $(END)$(RED)Program$(END)\n'
|
|
||||||
@$(RM) $(NAME)
|
|
||||||
@echo ""
|
|
||||||
|
|
||||||
# Restart (make re)
|
|
||||||
re: header fclean all
|
|
||||||
|
|
||||||
# Dependences for all
|
|
||||||
$(NAME): $(OBJ) $(LIB_OBJ)
|
|
||||||
@mkdir -p $(OBJDIRNAME)
|
|
||||||
@mkdir -p $(OBJDIRNAME)/$(LIBDIRNAME)
|
|
||||||
@mkdir -p $(OBJDIRNAME)/$(SRCDIRNAME)
|
|
||||||
@printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n'
|
|
||||||
@ar rc $(NAME) $(OBJ) $(OBJBonus)
|
|
||||||
@ranlib $(NAME)
|
|
||||||
# Creating the objects
|
|
||||||
$(OBJDIRNAME)/%.o: %.c
|
|
||||||
@mkdir -p $(dir $@)
|
|
||||||
@printf '$(GREY) Building $(END)$(GREEN)$<$(END)\n'
|
|
||||||
@cc $(CFLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
# Header
|
|
||||||
header:
|
|
||||||
@clear
|
|
||||||
@printf '\n\n'
|
|
||||||
@printf '$(GOLD) ******* ****** ******* $(END)\n'
|
|
||||||
@printf '$(GOLD) ****** *** ******* $(END)\n'
|
|
||||||
@printf '$(GOLD) ******* * ******* $(END)\n'
|
|
||||||
@printf '$(GOLD) ****** ******* $(END)\n'
|
|
||||||
@printf '$(GOLD) ******* ******* $(END)\n'
|
|
||||||
@printf '$(GOLD) ******************* ******* * $(END)\n'
|
|
||||||
@printf '$(GOLD) ******************* ******* *** $(END)\n'
|
|
||||||
@printf '$(GOLD) ****** ******* ****** $(END)\n'
|
|
||||||
@printf '$(GOLD) ****** $(END)\n'
|
|
||||||
@printf '$(GOLD) ****** $(END)\n'
|
|
||||||
@printf '$(GREY) Made by rparodi$(END)\n\n'
|
|
||||||
|
|
||||||
# Footer
|
|
||||||
footer:
|
|
||||||
@printf "\n"
|
|
||||||
@printf "$(GOLD) ,_ _,$(END)\n"
|
|
||||||
@printf "$(GOLD) | \\___//|$(END)\n"
|
|
||||||
@printf "$(GOLD) |=6 6=|$(END)\n"
|
|
||||||
@printf "$(GOLD) \\=._Y_.=/$(END)\n"
|
|
||||||
@printf "$(GOLD) ) \` ( ,$(END)\n"
|
|
||||||
@printf "$(GOLD) / \\ (('$(END)\n"
|
|
||||||
@printf "$(GOLD) | | ))$(END)\n"
|
|
||||||
@printf "$(GOLD) /| | | |\\_//$(END)\n"
|
|
||||||
@printf "$(GOLD) \\| |._.| |/-\`$(END)\n"
|
|
||||||
@printf "$(GOLD) '\"' '\"'$(END)\n"
|
|
||||||
@printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n'
|
|
||||||
|
|
||||||
# Phony
|
|
||||||
.PHONY: all bonus clean fclean re
|
|
||||||
|
|
||||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
||||||
-include ${OBJ:.o=.d}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_math.h :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/05/04 12:16:08 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/29 16:22:10 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_i8 sign;
|
|
||||||
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 *int_len, t_usize *float_len, t_u8 *sign);
|
|
||||||
t_error ft_init_numbers(t_str str, t_number *nb);
|
|
||||||
char **ft_split(char const *s, char c);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,76 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* 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
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_split.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/09 13:56:02 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/28 15:39:50 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "../includes/ft_math.h"
|
|
||||||
|
|
||||||
static int count_words(const char *str, char sep)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int count;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
count = 0;
|
|
||||||
while (str[i])
|
|
||||||
{
|
|
||||||
while (str[i] == sep && str[i])
|
|
||||||
i++;
|
|
||||||
if (str[i] != sep && str[i])
|
|
||||||
{
|
|
||||||
while (str[i] != sep && str[i])
|
|
||||||
i++;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (count);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *ft_strndup(const char *s, int j)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char *str;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
str = (char *)malloc((j + 1));
|
|
||||||
if (!str)
|
|
||||||
return (NULL);
|
|
||||||
while (s[i] && i < j)
|
|
||||||
{
|
|
||||||
str[i] = s[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
str[i] = '\0';
|
|
||||||
return (str);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char **ext_w(char **words_array, const char *str, char sep, int size)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
j = 0;
|
|
||||||
while (j < size)
|
|
||||||
{
|
|
||||||
while (str[i] == sep && str[i])
|
|
||||||
i++;
|
|
||||||
str = str + i;
|
|
||||||
i = 0;
|
|
||||||
while (str[i] != sep && str[i])
|
|
||||||
i++;
|
|
||||||
words_array[j++] = ft_strndup(str, i);
|
|
||||||
str = str + i;
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
words_array[j] = 0;
|
|
||||||
return (words_array);
|
|
||||||
}
|
|
||||||
|
|
||||||
char **ft_split(char const *s, char c)
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
char **words_array;
|
|
||||||
|
|
||||||
size = count_words(s, c);
|
|
||||||
words_array = (char **)malloc(sizeof(char *) * (size + 1));
|
|
||||||
if (!words_array)
|
|
||||||
return (NULL);
|
|
||||||
if (size == 0)
|
|
||||||
{
|
|
||||||
words_array[0] = NULL;
|
|
||||||
return (words_array);
|
|
||||||
}
|
|
||||||
words_array = ext_w(words_array, s, c, size);
|
|
||||||
return (words_array);
|
|
||||||
}
|
|
||||||
37
math/main.c
37
math/main.c
|
|
@ -1,37 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* main.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/05/27 14:41:26 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/29 16:16:28 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "./includes/ft_math.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
t_number *nb;
|
|
||||||
|
|
||||||
nb = (t_number *)malloc(sizeof(t_number));
|
|
||||||
if (argc != 2)
|
|
||||||
{
|
|
||||||
printf("Usage: %s <string>\n", argv[0]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (argc == 2)
|
|
||||||
{
|
|
||||||
if (ft_init_numbers(argv[1], nb) == ERROR)
|
|
||||||
{
|
|
||||||
printf("Error\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf("Number = %s \n(int: %s, %zu) (float: %s, %zu)\n", nb->number, nb->int_part, nb->int_size, nb->float_part, nb->float_size);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_equal.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/05/04 15:43:23 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/28 14:12:46 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "../../includes/ft_math.h"
|
|
||||||
|
|
||||||
// char ft_equal(double nb1, double nb2)
|
|
||||||
// {
|
|
||||||
// if (nb1 == nb2)
|
|
||||||
// return (1);
|
|
||||||
// else
|
|
||||||
// return (0);
|
|
||||||
// }
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_is_greater.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/05/04 14:29:09 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/28 14:13:23 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "../../includes/ft_math.h"
|
|
||||||
|
|
||||||
// char ft_is_greater_equal(double nb1, double nb2)
|
|
||||||
// {
|
|
||||||
// if (nb1 >= nb2)
|
|
||||||
// return (1);
|
|
||||||
// else
|
|
||||||
// return (0);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// char ft_is_greater(double nb1, double nb2)
|
|
||||||
// {
|
|
||||||
// if (nb1 > nb2)
|
|
||||||
// return (1);
|
|
||||||
// else
|
|
||||||
// return (0);
|
|
||||||
// }
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_is_less.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/05/04 14:39:13 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/28 14:12:59 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "../../includes/ft_math.h"
|
|
||||||
|
|
||||||
// char ft_is_less_equal(double nb1, double nb2)
|
|
||||||
// {
|
|
||||||
// if (nb1 <= nb2)
|
|
||||||
// return (1);
|
|
||||||
// else
|
|
||||||
// return (0);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// char ft_is_less(double nb1, double nb2)
|
|
||||||
// {
|
|
||||||
// if (nb1 < nb2)
|
|
||||||
// return (1);
|
|
||||||
// else
|
|
||||||
// return (0);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_split.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2023/11/09 13:56:02 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/28 15:39:50 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "../includes/ft_math.h"
|
|
||||||
|
|
||||||
static int count_words(const char *str, char sep)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int count;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
count = 0;
|
|
||||||
while (str[i])
|
|
||||||
{
|
|
||||||
while (str[i] == sep && str[i])
|
|
||||||
i++;
|
|
||||||
if (str[i] != sep && str[i])
|
|
||||||
{
|
|
||||||
while (str[i] != sep && str[i])
|
|
||||||
i++;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (count);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *ft_strndup(const char *s, int j)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char *str;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
str = (char *)malloc((j + 1));
|
|
||||||
if (!str)
|
|
||||||
return (NULL);
|
|
||||||
while (s[i] && i < j)
|
|
||||||
{
|
|
||||||
str[i] = s[i];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
str[i] = '\0';
|
|
||||||
return (str);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char **ext_w(char **words_array, const char *str, char sep, int size)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
j = 0;
|
|
||||||
while (j < size)
|
|
||||||
{
|
|
||||||
while (str[i] == sep && str[i])
|
|
||||||
i++;
|
|
||||||
str = str + i;
|
|
||||||
i = 0;
|
|
||||||
while (str[i] != sep && str[i])
|
|
||||||
i++;
|
|
||||||
words_array[j++] = ft_strndup(str, i);
|
|
||||||
str = str + i;
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
words_array[j] = 0;
|
|
||||||
return (words_array);
|
|
||||||
}
|
|
||||||
|
|
||||||
char **ft_split(char const *s, char c)
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
char **words_array;
|
|
||||||
|
|
||||||
size = count_words(s, c);
|
|
||||||
words_array = (char **)malloc(sizeof(char *) * (size + 1));
|
|
||||||
if (!words_array)
|
|
||||||
return (NULL);
|
|
||||||
if (size == 0)
|
|
||||||
{
|
|
||||||
words_array[0] = NULL;
|
|
||||||
return (words_array);
|
|
||||||
}
|
|
||||||
words_array = ext_w(words_array, s, c, size);
|
|
||||||
return (words_array);
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_add.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/05/27 12:27:41 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/28 14:09:12 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "../../includes/ft_math.h"
|
|
||||||
|
|
||||||
t_error ft_add(t_number *a, t_number *b)
|
|
||||||
{
|
|
||||||
// t_number result;
|
|
||||||
// t_usize index;
|
|
||||||
|
|
||||||
if (a == NULL || b == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
// index = 0;
|
|
||||||
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_pow.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/05/04 12:14:51 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/27 14:37:29 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "../../includes/ft_math.h"
|
|
||||||
|
|
||||||
long long int ft_pow(long long int base, long long int exponent)
|
|
||||||
{
|
|
||||||
(void)base;
|
|
||||||
(void)exponent;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// int main(void)
|
|
||||||
// {
|
|
||||||
// printf("Original: %f\n", pow(3, 3));
|
|
||||||
// printf("HomeMade: %lld\n", ft_pow(3, 3));
|
|
||||||
// }
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_init_numbers.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/05/28 13:41:03 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/29 16:23:35 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "../../includes/ft_math.h"
|
|
||||||
|
|
||||||
t_error ft_init_numbers(t_str str, t_number *nb)
|
|
||||||
{
|
|
||||||
t_usize int_size;
|
|
||||||
t_usize float_size;
|
|
||||||
t_u8 sign;
|
|
||||||
t_str *tmp;
|
|
||||||
|
|
||||||
int_size = 0;
|
|
||||||
float_size = 0;
|
|
||||||
sign = 1;
|
|
||||||
if (nb == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
if (ft_nblen(str, &int_size, &float_size, &sign) == ERROR)
|
|
||||||
return (ERROR);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nb->number = str;
|
|
||||||
tmp = ft_split(str, '.');
|
|
||||||
nb->sign = sign;
|
|
||||||
nb->int_part = tmp[0];
|
|
||||||
nb->float_part = tmp[1];
|
|
||||||
nb->int_size = int_size;
|
|
||||||
nb->float_size = float_size;
|
|
||||||
}
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* ft_nblen.c :+: :+: :+: */
|
|
||||||
/* +:+ +:+ +:+ */
|
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
|
||||||
/* +#+#+#+#+#+ +#+ */
|
|
||||||
/* Created: 2024/05/27 12:30:54 by rparodi #+# #+# */
|
|
||||||
/* Updated: 2024/05/29 16:20:52 by rparodi ### ########.fr */
|
|
||||||
/* */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
|
|
||||||
#include "../../includes/ft_math.h"
|
|
||||||
|
|
||||||
t_error ft_counter(const t_str str, t_usize *i)
|
|
||||||
{
|
|
||||||
if (str[(*i)] >= '0' && str[(*i)] <= '9')
|
|
||||||
(*i)++;
|
|
||||||
else
|
|
||||||
return (ERROR);
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
t_error ft_nblen(const t_str str, t_usize *int_len, t_usize *float_len, t_u8 *sign)
|
|
||||||
{
|
|
||||||
t_usize i;
|
|
||||||
|
|
||||||
(*int_len) = 0;
|
|
||||||
(*float_len) = 0;
|
|
||||||
(*sign) = 1;
|
|
||||||
i = 0;
|
|
||||||
if (str == NULL)
|
|
||||||
return (ERROR);
|
|
||||||
if (str[i] == '-')
|
|
||||||
{
|
|
||||||
(*sign) = -1;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
while (str[i] != '.' && str[i] != '\0')
|
|
||||||
ft_counter(str, &i);
|
|
||||||
(*int_len) = i;
|
|
||||||
if (str[i] == '.')
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
while (str[i] != '\0')
|
|
||||||
ft_counter(str, &i);
|
|
||||||
(*float_len) = i - (*int_len) - 1;
|
|
||||||
}
|
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
|
||||||
43
math/tags
43
math/tags
|
|
@ -1,43 +0,0 @@
|
||||||
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
|
||||||
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
|
||||||
!_TAG_OUTPUT_EXCMD mixed /number, pattern, mixed, or combineV2/
|
|
||||||
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
|
|
||||||
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
|
|
||||||
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
|
|
||||||
!_TAG_PROC_CWD /home/rparodi/Documents/ft_math/ //
|
|
||||||
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
|
|
||||||
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
|
|
||||||
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
|
|
||||||
!_TAG_PROGRAM_VERSION 5.9.0 //
|
|
||||||
$(NAME) Makefile /^$(NAME): $(OBJ) $(LIB_OBJ)$/;" t
|
|
||||||
$(OBJDIRNAME)/%.o Makefile /^$(OBJDIRNAME)\/%.o: %.c$/;" t
|
|
||||||
CC Makefile /^CC = cc$/;" m
|
|
||||||
CFLAGS Makefile /^CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD$/;" m
|
|
||||||
END Makefile /^END = \\033[0m$/;" m
|
|
||||||
FT_MATH includes/ft_math.h /^# define FT_MATH$/;" d
|
|
||||||
GOLD Makefile /^GOLD = \\033[38;5;220m$/;" m
|
|
||||||
GREEN Makefile /^GREEN = \\033[32m$/;" m
|
|
||||||
GREY Makefile /^GREY = \\033[0;90m$/;" m
|
|
||||||
LIB Makefile /^LIB = $/;" m
|
|
||||||
LIBDIRNAME Makefile /^LIBDIRNAME = libft$/;" m
|
|
||||||
LIB_OBJ Makefile /^LIB_OBJ = $(addprefix $(OBJDIRNAME)\/,$(LIB:.c=.o))$/;" m
|
|
||||||
NAME Makefile /^NAME = pipex$/;" m
|
|
||||||
OBJ Makefile /^OBJ = $(addprefix $(OBJDIRNAME)\/,$(SRC:.c=.o))$/;" m
|
|
||||||
OBJDIRNAME Makefile /^OBJDIRNAME = .\/objects$/;" m
|
|
||||||
RED Makefile /^RED = \\033[0;31m$/;" m
|
|
||||||
RM Makefile /^RM = rm -rf$/;" m
|
|
||||||
SRC Makefile /^SRC = $/;" m
|
|
||||||
SRCDIRNAME Makefile /^SRCDIRNAME = sources$/;" m
|
|
||||||
all Makefile /^all: header $(NAME) footer$/;" t
|
|
||||||
bonus Makefile /^bonus: header $(OBJ) $(LIB_OBJ) footer$/;" t
|
|
||||||
clean Makefile /^clean:$/;" t
|
|
||||||
fclean Makefile /^fclean: clean$/;" t
|
|
||||||
footer Makefile /^footer:$/;" t
|
|
||||||
ft_equal sources/ft_equal.c /^char ft_equal(double nb1, double nb2)$/;" f typeref:typename:char
|
|
||||||
ft_is_greater sources/ft_is_greater.c /^char ft_is_greater(double nb1, double nb2)$/;" f typeref:typename:char
|
|
||||||
ft_is_greater_equal sources/ft_is_greater.c /^char ft_is_greater_equal(double nb1, double nb2)$/;" f typeref:typename:char
|
|
||||||
ft_is_less sources/ft_is_less.c /^char ft_is_less(double nb1, double nb2)$/;" f typeref:typename:char
|
|
||||||
ft_is_less_equal sources/ft_is_less.c /^char ft_is_less_equal(double nb1, double nb2)$/;" f typeref:typename:char
|
|
||||||
ft_pow sources/ft_pow.c /^long long int ft_pow(long long int base, long long int exponent)$/;" f typeref:typename:long long int
|
|
||||||
header Makefile /^header:$/;" t
|
|
||||||
re Makefile /^re: header fclean all$/;" t
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue