fork download
  1. #include <iostream>
  2. #include <math.h>
  3. #include <stdio.h>
  4. using namespace std;
  5.  
  6. inline int foo(float a, float r, float g, float b)
  7. {
  8. unsigned int num = ((((long)ceil((a * 255.0) - 0.5)) << 24)
  9. + (((long)ceil((r * 255.0) - 0.5)) << 16)
  10. + (((long)ceil((g * 255.0) - 0.5)) << 8)
  11. + (((long)ceil((b * 255.0) - 0.5))));
  12. return num;
  13. }
  14.  
  15. int main() {
  16. printf("%#08x\n", foo(0.5f, 0, 0.5, 0));
  17. return 0;
  18. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
0x7f007f00