[ create a new paste ] login | about

Link: http://codepad.org/YvOMwrKe    [ raw code | fork ]

C++, pasted on Jan 17:
#include <stdint.h>
#include <stdlib.h>

inline int16_t getContainerPos(int16_t p, int16_t d)
{
	return (p>=0 ? p : p-d+1) / d;
}

inline int16_t getContainerPos2(int16_t p, int16_t d)
{
	return (p>=0 ? p : p-d+1) / d;
}

int main(void)
{
	volatile int16_t r;
	int16_t d;

	for (size_t i = 0; i < 4000000; i++) {
		for (size_t j = 0; j < 100; j++) {
			d = rand();
			if (d == 0)
				d++;
			r = getContainerPos(rand(), d);
		}
	}
	return 0;
}


Create a new paste based on this one


Comments: