feat: finishing the ex00 of the module 06

This commit is contained in:
Raphael 2025-03-24 15:17:27 +01:00
parent d32b496a87
commit 6631b3042a
4 changed files with 59 additions and 53 deletions

View file

@ -6,11 +6,12 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/22 22:06:48 by rparodi #+# #+# */
/* Updated: 2025/03/22 22:10:24 by rparodi ### ########.fr */
/* Updated: 2025/03/24 14:38:51 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "ScalarConverter.hpp"
#include "color.hpp"
bool isChar(std::string const &str) {
if (str.length() == 1 && !std::isdigit(str[0])) {
@ -21,11 +22,8 @@ bool isChar(std::string const &str) {
void convertChar(std::string const &str) {
char toChar = str[0];
int toInt = static_cast<int>(toChar);
float toFloat = static_cast<float>(toChar);
double toDouble = static_cast<double>(toChar);
std::cout << "Char: '" << toChar << "'" << std::endl;
std::cout << "Int: " << toInt << std::endl;
std::cout << "Float: " << toFloat << ".0f" << std::endl;
std::cout << "Double: " << toDouble << ".0" << std::endl;
std::cout << CLR_BLUE << "Char:\t'" << CLR_GOLD << toChar << CLR_BLUE << "'" << CLR_RESET << std::endl;
std::cout << CLR_BLUE << "Int:\t" << CLR_GOLD << static_cast<int>(toChar) << CLR_RESET << std::endl;
std::cout << CLR_BLUE << "Float:\t" << CLR_GOLD << std::fixed << std::setprecision(1) << static_cast<float>(toChar) << "f" << CLR_RESET << std::endl;
std::cout << CLR_BLUE << "Double:\t" << CLR_GOLD << std::fixed << std::setprecision(1) << static_cast<double>(toChar) << CLR_RESET << std::endl;
}