Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <time.h>
#include <math.h>
int main(int argc, char*argv[]) {
int N = 1000*1000*1000;
double i;
long double j;
clock_t start, end;
start = clock();
@aarchiba
aarchiba / howfast.c
Created September 18, 2019 16:46
Quick check of how fast double, long double, and quad precision math is
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <quadmath.h>
int main(int argc, char*argv[]) {
int N = 100*1000*1000;
double i;
long double j;
__float128 k;
@aarchiba
aarchiba / longdouble.c
Created September 18, 2019 16:27
Quick test for longdouble precision
#include <stdio.h>
int main(int argc, char*argv[]) {
long double one = 1;
long double eps = 1;
long double old_eps = 1;
while(one+eps != one) {
old_eps = eps;
eps /= 2;
}
@aarchiba
aarchiba / weightedpoisson
Last active December 12, 2015 00:49
Estimating Poisson uncertainties when the events are weighted
{
"metadata": {
"name": "poissonplus"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{