Comments (1)
int get_val(char c) {
assert(('0' <= c and c <= '9') or ('a' <= c and c <= 'f'));
if ('0' <= c and c <= '9')
return c - '0';
else
return c - 'a' + 10;
}
BigInt hex_to_BigInt(const std::string& hex) {
assert(!hex.empty());
BigInt res = 0, p = 1;
for (auto it = hex.rbegin(); it != hex.rend(); it++) {
res += p * get_val(*it);
p *= 16;
}
return res;
}
I had something similar to this in mind. Do we have any library specific optimizations?
Obviously we would need to handle lots of edge cases in original implementation.
from bigint.
Related Issues (20)
- sqrt returns incorrect result for inputs that are a perfect square HOT 1
- Build fails in CLion 2017.3 HOT 1
- Add support for hexadecimal string in constructor HOT 9
- Should is_valid_number be able to handle negative numbers? HOT 2
- big_random might return a BigInt having a value with a leading 0 HOT 4
- Hex support HOT 1
- `big_random` function: mistake in description and better implementation suggestion HOT 3
- Improve README
- sqrt() always returns 1 HOT 4
- Improve the documentation related to development
- Support bitwise operation HOT 12
- a bug in DIV HOT 1
- MacOS Invalid token in expression during Make HOT 1
- Cannot compile on msvc2019, cmake, when trying to compile the release 0.50 HOT 1
- Very slow compared to the GNU MP Bignum Library HOT 3
- `log()` support
- Elaborate instructions on which files to #include for which functions/operators HOT 2
- Fix for MSVC?
- Invalid string access on modulo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigint.