Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
/* Naive (conditional) and optimized (branchless) absolute value */
#include <ctime>
#include <iostream>
#include <functional>
using namespace std;
int abs_naive(const int i) {
return i < 0 ? -i : i;