-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add ft_swap, ft_ntohs implementation
- Loading branch information
Showing
5 changed files
with
46 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
# By: lumenthi <[email protected]> +#+ +:+ +#+ # | ||
# +#+#+#+#+#+ +#+ # | ||
# Created: 2018/01/04 10:37:11 by lumenthi #+# #+# # | ||
# Updated: 2022/10/11 11:10:04 by lumenthi ### ########.fr # | ||
# Updated: 2022/11/25 17:41:20 by lumenthi ### ########.fr # | ||
# # | ||
# **************************************************************************** # | ||
|
||
|
@@ -117,7 +117,8 @@ SRCS = ft_atoi.c \ | |
ft_strjoin_free.c \ | ||
ft_rmchar.c \ | ||
time_utils.c \ | ||
ft_abs.c | ||
ft_abs.c \ | ||
ft_swap.c | ||
|
||
OBJDIR = objs | ||
OBJS = $(addprefix $(OBJDIR)/, $(SRCS:.c=.o)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_swap.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: lumenthi <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/02/10 12:01:16 by lumenthi #+# #+# */ | ||
/* Updated: 2022/11/25 17:45:11 by lumenthi ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "libft.h" | ||
|
||
uint16_t swap_uint16(uint16_t nb) | ||
{ | ||
nb = (nb << 8) | (nb >> 8); | ||
return (nb); | ||
} | ||
|
||
uint32_t swap_uint32(uint32_t nb) | ||
{ | ||
nb = ((nb & 0x000000FF) << 24 | | ||
(nb & 0x0000FF00) << 8 | | ||
(nb & 0x00FF0000) >> 8 | | ||
(nb & 0xFF000000) >> 24); | ||
return (nb); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: lumenthi <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2017/11/11 10:50:56 by lumenthi #+# #+# */ | ||
/* Updated: 2022/10/11 11:10:36 by lumenthi ### ########.fr */ | ||
/* Updated: 2022/11/25 17:45:30 by lumenthi ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -121,5 +121,7 @@ uint64_t get_time(void); | |
int ft_abs(int nb); | ||
long ft_labs(long nb); | ||
long long ft_llabs(long long nb); | ||
uint16_t swap_uint16(uint16_t nb); | ||
uint32_t swap_uint32(uint32_t nb); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters