From b13cd117a7957f9d86ec2986b47349979325a854 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Mon, 14 Dec 2020 11:18:40 +0100 Subject: Fixing nanf not recognized in cpp06/00, Fixing serialization size to 52 bytes --- cpp06/ex00/Makefile | 4 ++-- cpp06/ex00/main.cpp | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'cpp06/ex00') diff --git a/cpp06/ex00/Makefile b/cpp06/ex00/Makefile index e0de1f1..f548628 100644 --- a/cpp06/ex00/Makefile +++ b/cpp06/ex00/Makefile @@ -6,14 +6,14 @@ # By: charles +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2020/04/15 09:59:30 by charles #+# #+# # -# Updated: 2020/12/13 16:00:15 by charles ### ########.fr # +# Updated: 2020/12/14 10:53:21 by cacharle ### ########.fr # # # # **************************************************************************** # NAME = convert CXX = clang++ -CXXFLAGS = -std=c++98 -Wall -Wextra -Werror +CXXFLAGS = -Wall -Wextra -Werror SRC = main.cpp OBJ = $(SRC:.cpp=.o) diff --git a/cpp06/ex00/main.cpp b/cpp06/ex00/main.cpp index a0ef7f8..b66ff4e 100644 --- a/cpp06/ex00/main.cpp +++ b/cpp06/ex00/main.cpp @@ -6,7 +6,7 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/16 10:54:10 by charles #+# #+# */ -/* Updated: 2020/12/13 17:11:08 by charles ### ########.fr */ +/* Updated: 2020/12/14 10:53:10 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -58,6 +58,8 @@ bool is_float(std::string input) { if (input[input.length() - 1] != 'f') return false; + if (input == "nanf" || input == "+inff" || input == "-inff") + return true; if (input.find('.') == std::string::npos) input.insert(input.length() - 1, ".0"); return is_double(input.substr(0, input.length() - 1)); @@ -120,7 +122,6 @@ int main(int argc, char **argv) return 1; } - if (CHAR_MIN <= x && x <= CHAR_MAX && !std::isnan(x) && !std::isinf(x)) { char c = static_cast(x); -- cgit