Skip to content

monolithed/to_numeric

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

to_numeric

Converts a string value to numeric type

Dependencies

C++11

Installation

git clone [email protected]:monolithed/to_numeric.git

Place the to_numeric.hpp into the working directory and include like:

#inclide "to_numeric.hpp"

Using

#include <iostream>
#include "../to_numeric.hpp"

int main()
{
	// std::string -> unsigned long long
	std::cout << nott::to_numeric<unsigned long long>("100000000000000ULL") << std::endl;

	// float -> int
	std::cout << nott::to_numeric<float>(10.0001f) << std::endl;

	// char -> int
	std::cout << nott::to_numeric<int>('1') << std::endl;

	return 0;
}

Supported operations

std::string / char *  ->  int
std::string / char *  ->  short
std::string / char *  ->  signed
std::string / char *  ->  signed int
std::string / char *  ->  unsigned int
std::string / char *  ->  unsigned short
std::string / char *  ->  long
std::string / char *  ->  long int
std::string / char *  ->  long long
std::string / char *  ->  long long int
std::string / char *  ->  unsigned long
std::string / char *  ->  unsigned long int
std::string / char *  ->  unsigned long long
std::string / char *  ->  unsigned long long int
std::string / char *  ->  float
std::string / char *  ->  double
std::string / char *  ->  long double
int                   ->  int
float                 ->  double

##.

  • This library is licensed under the MIT license

About

Converts a string value to numeric type

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published