This commit is contained in:
EniumRaphael 2024-05-30 16:14:32 +02:00
parent 2db43419ed
commit 84705f955e
3 changed files with 27 additions and 28 deletions

View file

@ -6,34 +6,35 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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"
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_i64 tmp;
t_i32 i;
t_i64 tmp;
i = 0;
tmp = base;
if (exponent < 0)
return (ERROR);
while (i < exponent)
return (ERROR);
while (i < exponent)
{
(*result) *= base;
if ((*result) / base != tmp)
return (ERROR);
(*result) *= base;
if ((*result) / base != tmp)
return (ERROR);
tmp = (*result);
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;
(*value)--;
@ -42,9 +43,9 @@ t_error ft_decrimented(t_i64 *value)
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;
(*value)++;