Normed
This commit is contained in:
parent
2db43419ed
commit
84705f955e
3 changed files with 27 additions and 28 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 15:33:53 by rparodi #+# #+# */
|
/* Created: 2024/05/30 15:33:53 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/05/30 16:07:58 by rparodi ### ########.fr */
|
/* Updated: 2024/05/30 16:12:59 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -52,11 +52,10 @@ t_error ft_divide(t_i32 first, t_i32 second, t_i64 *result)
|
||||||
return (NO_ERROR);
|
return (NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
t_error ft_modulo(t_i32 first, t_i32 second, t_i64 *result)
|
t_error ft_modulo(t_i32 first, t_i32 second, t_i64 *result)
|
||||||
{
|
{
|
||||||
if (second == 0) {
|
if (second == 0)
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
}
|
*result = first % second;
|
||||||
*result = first % second;
|
return (NO_ERROR);
|
||||||
return (NO_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,34 +6,35 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 15:51:55 by rparodi #+# #+# */
|
/* Created: 2024/05/30 15:51:55 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/05/30 16:04:33 by rparodi ### ########.fr */
|
/* Updated: 2024/05/30 16:14:04 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "operation.h"
|
#include "operation.h"
|
||||||
t_error ft_power(t_i32 base, t_i32 exponent, t_i64 *result)
|
|
||||||
|
t_error ft_power(t_i32 base, t_i32 exponent, t_i64 *result)
|
||||||
{
|
{
|
||||||
t_i32 i;
|
t_i32 i;
|
||||||
t_i64 tmp;
|
t_i64 tmp;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
tmp = base;
|
tmp = base;
|
||||||
if (exponent < 0)
|
if (exponent < 0)
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
while (i < exponent)
|
while (i < exponent)
|
||||||
{
|
{
|
||||||
(*result) *= base;
|
(*result) *= base;
|
||||||
if ((*result) / base != tmp)
|
if ((*result) / base != tmp)
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
tmp = (*result);
|
tmp = (*result);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return (NO_ERROR);
|
return (NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
t_error ft_decrimented(t_i64 *value)
|
t_error ft_decrimented(t_i64 *value)
|
||||||
{
|
{
|
||||||
t_i64 tmp;
|
t_i64 tmp;
|
||||||
|
|
||||||
tmp = *value;
|
tmp = *value;
|
||||||
(*value)--;
|
(*value)--;
|
||||||
|
|
@ -42,9 +43,9 @@ t_error ft_decrimented(t_i64 *value)
|
||||||
return (NO_ERROR);
|
return (NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
t_error ft_incrimented(t_i64 *value)
|
t_error ft_incrimented(t_i64 *value)
|
||||||
{
|
{
|
||||||
t_i64 tmp;
|
t_i64 tmp;
|
||||||
|
|
||||||
tmp = *value;
|
tmp = *value;
|
||||||
(*value)++;
|
(*value)++;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/30 16:03:29 by rparodi #+# #+# */
|
/* Created: 2024/05/30 16:03:29 by rparodi #+# #+# */
|
||||||
/* Updated: 2024/05/30 16:05:30 by rparodi ### ########.fr */
|
/* Updated: 2024/05/30 16:14:22 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -20,10 +20,9 @@ t_error ft_add(t_i32 first, t_i32 second, t_i64 *result);
|
||||||
t_error ft_subtract(t_i32 first, t_i32 second, t_i64 *result);
|
t_error ft_subtract(t_i32 first, t_i32 second, t_i64 *result);
|
||||||
t_error ft_multiply(t_i32 first, t_i32 second, t_i64 *result);
|
t_error ft_multiply(t_i32 first, t_i32 second, t_i64 *result);
|
||||||
t_error ft_divide(t_i32 first, t_i32 second, t_i64 *result);
|
t_error ft_divide(t_i32 first, t_i32 second, t_i64 *result);
|
||||||
t_error ft_modulo(t_i32 first, t_i32 second, t_i64 *result);
|
t_error ft_modulo(t_i32 first, t_i32 second, t_i64 *result);
|
||||||
t_error ft_power(t_i32 base, t_i32 exponent, t_i64 *result);
|
t_error ft_power(t_i32 base, t_i32 exponent, t_i64 *result);
|
||||||
t_error ft_incrimented(t_i64 *value);
|
t_error ft_incrimented(t_i64 *value);
|
||||||
t_error ft_decrimented(t_i64 *value);
|
t_error ft_decrimented(t_i64 *value);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue