Created
February 2, 2019 18:13
-
-
Save jdpage/943059bc486dfa270174ce03797d5f07 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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