Skip to content

Instantly share code, notes, and snippets.

@jdpage
Created February 2, 2019 18:13
Show Gist options
  • Save jdpage/943059bc486dfa270174ce03797d5f07 to your computer and use it in GitHub Desktop.
Save jdpage/943059bc486dfa270174ce03797d5f07 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <unistd.h>
#define BUFSIZE 1024
int main()
{
/* Pipe text into me! */
char data[BUFSIZE + 4];
ssize_t len;
while ((len = read(STDIN_FILENO, data + 4, BUFSIZE))) {
char *d = data;
float *z = (float *)(data + len + 1);
for (int k = 0; k < 4; k++) {
for (float *p = (float *)(++d); p < z; p++) {
*p *= *p >= 1.47573952589676412928e20f ? 5.421010862427522e-20f : 1.0f;
}
}
write(STDOUT_FILENO, d, len);
}
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment