Skip to content

Instantly share code, notes, and snippets.

View LBijaminas's full-sized avatar

Lukas Bijaminas LBijaminas

View GitHub Profile
@LBijaminas
LBijaminas / lfsr_20bit.c
Last active August 29, 2015 13:56
20-bit LFSR with a verification function to verify that it does not repeat after the period
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define MAX_PERIOD 1048575
void generateNums(int *);
void checkDups(int *);
int main(){
int genNums[MAX_PERIOD];
@LBijaminas
LBijaminas / pi_calc.c
Created October 23, 2013 22:52
Simple function to approximate the value of pi.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main(void) {
double x, y, i; // variables
double N0 = 0, Ntot = 100000000; // numbers that the numbers in the range and total numbers
double A; // area var
@LBijaminas
LBijaminas / hex_to_str.c
Last active December 23, 2015 03:39
C function to convert hexadecimal number to string. I was looking for it for the kernel I'm trying to make but couldn't find it, so wrote one myself. Hope this helps somebody.
char checkTheBits(unsigned char hByte);
char* hex_to_string(unsigned int n){
// output hexadecimal chars
unsigned char* location = &n; //get the location of the hex number
char value[9] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; // init null byte array
// array has 9 values, because last one reserved fur null terminator
unsigned char temp_char_l, temp_char_h; // temporary vars
int i = 0, j = 7; // start at 7, because tested on little endian machine