Skip to content

Instantly share code, notes, and snippets.

View wesgarland's full-sized avatar

Wes Garland wesgarland

View GitHub Profile
@wesgarland
wesgarland / parse-float.c
Created March 2, 2022 00:40
C analogue of parse-float.js
/* CFLAGS=-O2 make parse-float */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main (int argc, const char *argv[])
{
const char *buf = "0.45494253843119004";
int i;
@wesgarland
wesgarland / parse-float.js
Created March 1, 2022 23:12
node-mysql2 parseFloat benchmarking
#! /usr/bin/env node
'use strict';
const minus = '-'.charCodeAt(0);
const plus = '+'.charCodeAt(0);
// TODO: handle E notation
const dot = '.'.charCodeAt(0);
const exponent = 'e'.charCodeAt(0);
const exponentCapital = 'E'.charCodeAt(0);