Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cstdlib>
- using namespace std;
- int decToSystem(int x, int base, int output[]) {
- int i = 0;
- for(i = 0; x > 0; i++) {
- output[i] = x % base;
- x /= base;
- }
- return i;
- }
- int systemToDec(string x, int base) {
- int ph = 0;
- for(int i = 0; i < x.length(); i++) {
- int conv = (x.at(i) - '0');
- if(conv > 9) {
- conv -= 7;
- }
- ph += conv * pow(base, x.length()-i-1);
- }
- return ph;
- }
- int main() {
- int bits[1000];
- cout << systemToDec("FFFF", 16);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement