Skip to content

Instantly share code, notes, and snippets.


Stephen Canon stephentyrone

View GitHub Profile
View gist:228144648ee250a4ba07
#import <Foundation/Foundation.h>
#import <mach/mach_time.h>
#import <simd/simd.h>
NSTimeInterval SecondsFromMachTimeInterval(uint64_t machTimeInterval) {
static double timeScaleSeconds = 0.0;
if (timeScaleSeconds == 0.0) {
stephentyrone /
Last active Sep 15, 2017
Notes on how min/max might be defined.

Defining min and max

Most definitions of floating-point min and max are badly flawed; this note explains what axioms these functions should have, illustrates the problems with existing definitions, and explores the options for fixing the situation.

Note: min and max should be symmetric, so it suffices to restrict our attention to one of them. For most of the rest of this document, I'll explain everything using min. The appropriate modifications to get max should generally be pretty clear.

Desired axioms

The first two axioms capture the meaning of minimum; they will likely seem completely obvious (possible the point of absurdity).