Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Binary to Integer (C)
// Author: Ice Scripter /* Inspired by the dude who made Binary to Integers / Integers to Binary in lua https://rextester.com/discussion/HTUOX30484/ NOTES: I will probably update this and make my own exp func to eliminate the math library I will also update this to have both b2i and i2b like that one guy I also plan on making this an actual function and not just running in the main func */ #include <stdio.h> #include <math.h> // Didn't want to use an extra library but I didn't want to make my own exp func lol // Make sure to add "-lm" in your compiler arguments since this library is in use. int main() { const unsigned int SIZE_OF_BYTE = 8; char input[8] = "00001101"; unsigned int output = 0; for (int i = SIZE_OF_BYTE-1; i >= 0; i--) { output += (int) (input[i]-48) * ( pow (2, ((i- (SIZE_OF_BYTE-1) )*-1) )); } printf("Output: %d", output); }
run
|
edit
|
history
|
help
1
IndiSelSort
extra causes class UK assisment
algo de avance
Absolute valu
tyiy
Spring 2017 Project 2 v1.2
Pattern 13
Memory leak
18BCE2182 ASSESS_2 Q-1
MATRIZ DE CADENAS