[ create a new paste ] login | about

AaronMiller

Name: Aaron Miller
Email:
Site/Blog: http://aaronm.nuclearglory.com/
Location: Roseville, CA (USA)
Default language: C++
Favorite languages: TrumpScript
About: no u

Saved pastes by AaronMiller:

C, pasted on Jul 9:
1
2
3
4
5
#include <stdint.h>
#include <stdio.h>

int muldiv(int a, int b, int c) {
    int abh, abl;
...
view (40 lines, 10 lines of output)
Plain Text, pasted on Sep 16:
1
2
3
4
5
【Kud】
「Nishizono-san, hello! Would you care for some green tea?」

【Voice】
「Not so fast!」
...
view (84 lines)
C, pasted on Oct 30:
1
2
3
4
5
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
...
view (9 lines, 2 lines of output)
Plain Text, pasted on Oct 13:
1
2
3
4
5
[DefineVars=True]

Do

	Local s$ = "int main()\n{\na\tdoStuff();\n\treturn 0;\n}"
...
view (13 lines)
C++, pasted on Aug 7:
1
2
3
4
// Select which engine to use for rendering
// 0: Nuclear Fusion will be used -- shows the bugs
// 1: Raw Direct3D 9 will be used -- shows how it's supposed to look
#define D3D9_MODE 0
...
view (784 lines, 1 comment)
Plain Text, pasted on Oct 13:
1
2
3
4
5
Repeat this riff a bit. Timing is a bit odd, try to get a
feel for what sounds right.

e||
B||
...
view (18 lines)
C, pasted on Sep 24:
1
2
3
4
5
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>

#if __GNUC__ || __clang__
...
view (35 lines, 16 lines of output)
C, pasted on Sep 15:
1
2
3
4
5
// http://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord
#include <stdio.h>
#include <stdlib.h>

#define haszero(v) (((v) - 0x01010101UL) & ~(v) & 0x80808080UL)
...
view (27 lines, 13 lines of output)
C++, pasted on Sep 10:
1
2
3
4
#include <cstdio>
#include <cstddef>
#include <cstdlib>
#include <cstring>
...
view (43 lines, 7 lines of output)
C++, pasted on Sep 10:
1
2
3
4
#include <cstdio>
#include <cstddef>
#include <cstdlib>
#include <cstring>
...
view (51 lines, 3 lines of output)
C, pasted on Aug 30:
1
2
3
4
5
#line 2
#include <stdio.h>
#include <stdlib.h>

char *int_to_string(int n, int radix) {
...
view (66 lines, 14 lines of output)
C++, pasted on Aug 30:
1
2
3
4
5
#include <cstdio>

class C {
public:
   C() { printf("+C\n"); }
...
view (24 lines, 4 lines of output)
C, pasted on Aug 19:
1
2
3
4
5
float _fsel_branchless(float f, float x, float y) {
	unsigned int msk, res;

	msk = -(((*(unsigned int *)&f)>>31)&1);
	res = ((msk)&*(unsigned int *)&y)|((~msk)&*(unsigned int *)&x);
...
view (16 lines)
C++, pasted on Aug 18:
1
2
3
4
5
#include <cmath>
#include <cstdio>
#include <cstdlib>

inline float clamp(float x, float lo, float hi) {
...
view (23 lines, 5 lines of output)
C, pasted on Jun 28:
1
2
3
4
#include <stdio.h>

int format(int x) {
  int seconds, minutes, hours;
...
view (23 lines, 3 lines of output, 1 comment)
C, pasted on Jun 16:
1
2
3
4
5
#if _WIN32
# define WIN32_LEAN_AND_MEAN 1
# include <windows.h>
#else
# include <sys/mman.h>
...
view (106 lines, 2 lines of output)
C, pasted on Jun 16:
1
2
3
4
5
#include <stdio.h>
#include <stdlib.h>

#if _MSC_VER || __INTEL_COMPILER
# include <intrin.h>
...
view (27 lines, 3 lines of output)
C++, pasted on May 22:
1
2
3
4
//
// Dictionary<T> Class from MkSDK
// Public Domain
//
...
view (198 lines, 6 lines of output)
C++, pasted on May 20:
1
2
3
4
#include <cstdio>
#include <cstddef>
#include <cstdlib>
#include <cstring>
...
view (43 lines, 1 line of output)
C++, pasted on May 20:
1
2
3
4
#include <cstdio>
#include <cstddef>
#include <cstdlib>
#include <cstring>
...
view (71 lines, 19 lines of output)
C++, pasted on May 14:
1
2
3
4
//PI = 4.0*atan(1.0)

#include <cstdio>
#include <cmath>
...
view (15 lines, 1 line of output)
C, pasted on May 14:
1
2
3
4
5
#include <GL/glfw.h>
#if _WIN32
# define WIN32_LEAN_AND_MEAN 1
# include <windows.h>
#endif
...
view (309 lines)
C, pasted on May 8:
1
2
3
4
5
#include <stdio.h>

/*
 * http://www.opengl.org/archives/resources/faq/technical/transformations.htm#tran0005
 */
...
view (21 lines, 5 lines of output)
C, pasted on Mar 16:
1
2
3
4
5
/*
 * Tiny String Library
 */
#include <stdio.h>
#include <stdarg.h>
...
view (247 lines, 1 line of output)
C, pasted on Mar 16:
1
2
3
4
5
/*
 * Tiny String Library
 */
#include <stdio.h>
#include <stdarg.h>
...
view (245 lines, 1 line of output)
C, pasted on Mar 12:
1
2
3
4
5
/* rcp-sqrt magic value: 0x5F3759DF */
#include <stdio.h>

void DispIntFloat(unsigned int i) {
  printf("0x%.8X = %f\n", i, *(float *)&i);
...
view (15 lines, 2 lines of output)
C, pasted on Mar 12:
1
2
3
4
#include <stdio.h>

float CopySign(float a, float b) {
  union { unsigned int i; float f; } A, B;
...
view (27 lines, 6 lines of output)
C, pasted on Mar 12:
1
2
3
4
#include <stdio.h>

float FloatSign(float a) {
  union { float f; int i; } v;
...
view (24 lines, 5 lines of output)
C, pasted on Mar 9:
1
2
3
4
5
/* "!a ? x : y" Optimization -- No Branching
   Written by Aaron J. Miller, 2012 */
#include <stdio.h>

#define selfromzero__(a) (-(((a) ^ -(a)) >> (sizeof(a)*8 - 1)))
...
view (19 lines, 6 lines of output)
C, pasted on Mar 9:
1
2
3
4
5
/*
 * Software Renderer Test -- Slight Revision
 * Written by Aaron J. Miller <nocannedmeat@gmail.com>; 20120309
 *  !!! MAY BE BUGGY; IS DEFINITELY INCOMPLETE !!!
 *
...
view (751 lines)
C, pasted on Mar 9:
1
2
3
4
5
#define memory(p,n) (!(p)&&(n) ? malloc((n)) : (p)&&(n) ? realloc((p), (n)) : (free((p)), (void *)0))

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
...
view (42 lines, 8 lines of output)
C, pasted on Mar 8:
1
2
3
4
5
#include <stdio.h>

int cpucount() {
#if __i386__||__i386||i386 || __x86_64__||__x86_64||x86_64
  int r;
...
view (16 lines, 1 line of output, 2 comments)
Plain Text, pasted on Mar 8:
1
2
3
4
5
Non-branching check for zero (1 if zero, 0 otherwise):

  (a ^ (-a)) >> (sizeof(a)*8 - 1)

If you need an entire mask (e.g., 1111 1111 1111 1111) if zero, then:
...
view (40 lines, 1 comment)
C, pasted on Mar 5:
1
2
3
4
5
#include <sys/time.h>
#include <stdio.h>

double Time() {
  struct timeval tv;
...
view (80 lines, 6 lines of output)
C, pasted on Mar 5:
1
2
3
4
5
#include <stdio.h>

/* rightmost zero-bit index */
int rmzbi(int bitfield) {
  int result;
...
view (75 lines, 19 lines of output, 1 comment)
C, pasted on Mar 2:
1
2
3
4
#include <pthread.h>
#include <stdio.h>

pthread_t g_thread;
...
view (21 lines, 3 lines of output, 1 comment)
C, pasted on Feb 29:
1
2
3
4
5
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/* tester functions */
...
view (60 lines, 2 lines of output)
C, pasted on Feb 28:
1
2
3
4
5
#include <stdio.h>
#include <string.h>

int sum(int x, int y) { return x+y; }
int dif(int x, int y) { return x-y; }
...
view (29 lines, 2 lines of output)
C, pasted on Feb 23:
1
2
3
4
/*
When selecting between two values without branching (e.g., in a virtual machine),
you can use a specific bit (or bit pattern) to select between the two values, like
so:
...
view (44 lines, 5 lines of output)
C, pasted on Feb 19:
1
2
3
4
5
#include <stdio.h>

typedef struct node_s *node_t;
struct node_s {
  int value;
...
view (116 lines, 26 lines of output)
C, pasted on Jan 20:
1
2
3
4
5
#include <stdio.h>

int GetPowerOfTwo(int x) {
  if ((x & (x - 1)) != 0) {
    x--;
...
view (50 lines, 16 lines of output)
Plain Text, pasted on Jan 8:
1
2
3
4
5
ALLFLAGS := -Wall -Weffc++
DEBUGFLAGS := -g -DDEBUG -D_DEBUG
RELEASEFLAGS := -O3 -s -fomit-frame-pointer -DNDEBUG

CFLAGS := $(ALLFLAGS) $(DEBUGFLAGS)
...
view (28 lines)
C++, pasted on Jan 7:
1
2
3
4
5
#include <cstdio>

// create a compressed float
// NOTE: in g++, references to this with constants are
//       automatically converted to constants, so this
...
view (23 lines, 1 line of output)
C, pasted on Nov 8:
1
2
3
4
5
// includes
#include <stdio.h>

// perform the pattern test
int wildcard(const char *source, const char *pattern) {
...
view (73 lines, 7 lines of output, 2 comments)
C++, pasted on Nov 5:
1
2
3
4
//from: http://msdn.microsoft.com/en-us/library/windows/desktop/ms680582%28v=vs.85%29.aspx
//see also: http://msdn.microsoft.com/en-us/library/windows/desktop/ms679351%28v=vs.85%29.aspx
void ErrorExit(LPTSTR lpszFunction) 
{ 
...
view (35 lines)
C++, pasted on Oct 3:
1
2
3
4
5
#include <cstdio>
#include <cstdarg>

inline void debugf_int(const char *file, unsigned int line, const char *fmt, ...) {
  static char buf[8192];
...
view (30 lines, 3 lines of output)
C, pasted on Oct 2:
1
2
3
4
5
#include <stdio.h>
#include <stdarg.h>

void debugf_int(const char *file, unsigned int line, const char *format, ...) {
  static char buf[8192];
...
view (23 lines, 3 lines of output)
C, pasted on Oct 2:
1
2
3
4
5
#include <stdio.h>

int get_xy(int *x, int *y) { *x=4; *y=5; }
#define tvar(a,b) ___temporary_var__##a##__##b##___
#define stringify(x) #x
...
view (19 lines, 1 line of output)
C, pasted on Sep 27:
1
2
3
4
5
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

#define VERSION_MAJOR 1
#define VERSION_MINOR 1
...
view (14 lines, 1 line of output, 1 comment)
C, pasted on Sep 27:
1
2
3
4
#ifndef __bool_true_false_are_defined
# define __bool_true_false_are_defined 1
typedef enum { false=0, true=1 } bool;
#endif
...
view (11 lines, 1 line of output)
C, pasted on Sep 27:
1
2
3
4
5
#include <stdbool.h>

#ifndef __bool_true_false_are_defined
# define __bool_true_false_are_defined 1
typedef enum { false=0, true=1 } bool;
...
view (13 lines, 1 line of output)
C, pasted on Sep 27:
1
2
3
4
#ifndef __bool_true_false_are_defined
# define __bool_true_false_are_defined 1
typedef enum { false=0, true=1 } bool;
#endif
...
view (13 lines, 1 line of output)
C, pasted on Sep 26:
1
2
3
4
5
#include <stdio.h>

#define XOR_SWAP(a, b) (((a) == (b)) || (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))))
#define XOR_PTRSWAP(a,b) {\
  union { void *p; size_t n; } __tA_##a = { .p=(void *)(a) },\
...
view (36 lines, 2 lines of output)
C, pasted on Sep 26:
1
2
3
4
5
#include <stdio.h>

#define XOR_SWAP(a, b) (((a) == (b)) || (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))))

int main() {
...
view (13 lines, 2 lines of output)
C, pasted on Sep 26:
1
2
3
4
5
#include <stdio.h>

#define XOR_SWAP(a, b) (((a) == (b)) || (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))))

int main() {
...
view (13 lines, 2 lines of output)
C++, pasted on Sep 20:
1
2
3
4
5
#include <cstdio>

inline unsigned int IntAbs(int x) { return ((x+(x>>31))^(x>>31)); }

static int _CalculateAngle(int center_x, int center_y, int extent_x, int extent_y) {
...
view (43 lines, 8 lines of output)
C, pasted on Sep 16:
1
2
3
4
5
#include <stdio.h>

int IntSign(int a) {
  return (1 | (a>>31));
}
...
view (24 lines, 2 lines of output)
C++, pasted on Sep 15:
1
2
3
4
5
/*
 * C versus C++ test
 * Structures with initializations based on field names
 */
#ifdef __cplusplus
...
view (19 lines, 2 lines of output)
C, pasted on Sep 15:
1
2
3
4
5
/*
 * C versus C++ test
 * Structures with initializations based on field names
 */
#ifdef __cplusplus
...
view (19 lines, 2 lines of output)
C++, pasted on Sep 14:
1
2
3
4
5
/*
 * Matrix Math (Column-major notation; row-major storage)
 * Written by Aaron J. Miller (20110914)
 *
 * All of the following routines (less helper functions) should create
...
view (434 lines, 15 lines of output)
C++, pasted on Sep 14:
1
2
3
4
5
#ifndef NUKEQUAT_H
#define NUKEQUAT_H

typedef struct {
	float w;
...
view (121 lines)
C, pasted on Sep 13:
1
2
3
4
5
/*
 * THANK YOU: http://predef.sourceforge.net/preos.html
 */
#include <stddef.h> /* size_t */
#include <errno.h>
...
view (120 lines, 1 line of output)
C, pasted on Sep 12:
1
2
3
4
5
#ifndef assert
# define _CRT_SECURE_NO_WARNINGS 1
# include <stdio.h>   /* fprintf  */
# include <stdlib.h>  /* exit     */
# include <errno.h>   /* errno    */
...
view (32 lines, 4 lines of output)
C++, pasted on Sep 11:
1
2
3
4
5
/*
 * Queue Class
 * Written by Aaron J. Miller (20110911)
 */
#include <cstdio>
...
view (136 lines, 10 lines of output, 1 comment)
C, pasted on Sep 11:
1
2
3
4
5
#include <stdio.h>

#define BEGIN_IFACE(T)\
	typedef struct T {\
		IFACE_FUNC(capture, int, (struct T *));\
...
view (19 lines, 1 line of output)
C++, pasted on Sep 11:
1
2
3
4
5
/*
 * Queue Class
 * Written by Aaron J. Miller (20110911)
 */
#include <cstdio>
...
view (112 lines, 7 lines of output, 2 comments)
C++, pasted on Sep 11:
1
2
3
4
5
/*
 * Queue Class
 * Written by Aaron J. Miller (20110911)
 */
#include <cstdio>
...
view (78 lines, 7 lines of output, 2 comments)
Plain Text, pasted on Aug 29:
1
2
3
4
5
Programming Language Idea

This is a class declaration. Note the usage of an uppercase letter as the first character.

  Vec3 x y z.
...
view (68 lines)
Scheme, pasted on Aug 20:
1
2
3
4
5
(define-syntax defun
  (syntax-rules ()
  ((defun a b ...) (define a (lambda b ...)))))

(defun get-sum (x y) (+ x y))
...
view (7 lines, 1 line of output)
C++, pasted on Jan 11:
1
2
3
4
5
/*
	Music Theory - Practice Algorithms
	Written by Aaron J. Miller (aaron.miller@axiosoftonline.com), 2010
	
	Octave 1 - 110Hz (1x)
...
view (152 lines, 262 lines of output)
C++, pasted on Jul 8:
1
2
3
4
5
/* Includes */
#include <stdio.h>

/* Check whether compilation is in C or C++ */
#if !defined(__cplusplus) && !defined(cplusplus)
...
view (45 lines, 1 line of output)
C++, pasted on Jul 6:
1
2
3
4
5
/*
    THEORY: Converting a real number to a "percentage" and
            finding the greatest common factor between the
            percentage and the base-percentage (in this case
            the value * ACCURACY and ACCURACY) will result
...
view (55 lines, 2 lines of output)
C++, pasted on Jul 6:
1
2
3
4
5
#include <stdio.h>

#define MAX_PRIMES 100

unsigned int g_curPrimeIndex = 0;
...
view (56 lines, 13 lines of output)
C, pasted on Jun 25:
1
2
3
4
5
/*
	Written by Aaron J. Miller, 2010
	NOTE
	  The Linux system call gets through before the stdout stream is flushed. You will therefore see the results of that first.
*/
...
view (62 lines, 14 lines of output)
C++, pasted on Apr 13:
1
2
3
4
5
/* Includes */
// POSIX Standard C Library
#include <stdio.h>

/* Declarations */
...
view (128 lines, 12 lines of output, 1 comment)