Skip to content

Instantly share code, notes, and snippets.

View pmj's full-sized avatar

Phil Dennis-Jordan pmj

View GitHub Profile
float rawBytesToFloat(const char* _buffer)
{
static_assert(sizeof(u_long_type) == sizeof(float),"sizes must match!");
u_long_type net_int;
memcpy(&net_int, _buffer, sizeof(net_int));
u_long_type host_int = asio::detail::socket_ops::network_to_host_long(net_int);
float result;
memcpy(&result, &host_int, sizeof(result));
return result;
}
@pmj
pmj / file-size.c
Last active December 31, 2015 19:18 — forked from weissi/file-size.c
#include <assert.h>
#include <dispatch/dispatch.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/event.h>
#include <sys/event.h>
#include <sys/select.h>