MCPcopy Create free account
hub / github.com/coin-or/CppAD / string2signed

Function string2signed

example/utility/to_string.cpp:25–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23namespace {
24 template <class Integer>
25 Integer string2signed(const std::string& s)
26 { Integer result = 0;
27 size_t index = 0;
28 if( s[0] == '-' )
29 { ++index;
30 while( index < s.size() )
31 result = Integer(10) * result - Integer(s[index++] - '0' );
32 }
33 else
34 { while( index < s.size() )
35 result = Integer(10) * result + Integer(s[index++] - '0' );
36 }
37 return result;
38 }
39 template <class Integer>
40 Integer string2unsigned(const std::string& s)
41 { Integer result = 0;

Callers

nothing calls this directly

Calls 2

IntegerFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected