/ libft / src / ft_basics / ft_log_b.c
ft_log_b.c
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   ft_log_b.c                                         :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: ll-hotel <ll-hotel@student.42lyon.fr>      +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2024/03/16 11:06:07 by ll-hotel          #+#    #+#             */
 9  /*   Updated: 2024/03/16 11:07:45 by ll-hotel         ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include <stdint.h>
14  
15  int	ft_log_b(int64_t n, int64_t base)
16  {
17  	int	log;
18  
19  	log = 0;
20  	n /= base;
21  	while (n && ++log)
22  		n /= base;
23  	return (log);
24  }
25  
26  int	ft_log_ub(uint64_t n, int64_t base)
27  {
28  	int	log;
29  
30  	log = 0;
31  	n /= base;
32  	while (n && ++log)
33  		n /= base;
34  	return (log);
35  }