https://alpacahack.com/daily/challenges/decimal-float-101-0

ã‚ŗãƒŧド

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void fail(char const*) __attribute__((noreturn));
void fail(char const* msg) {
  puts(msg);
  exit(1);
}

void win() {
  FILE* fin = fopen("flag.txt", "r");
  if (fin == NULL) {
    fail("fopen() failed.");
  }
  char flag[64] = {};
  fgets(flag, sizeof flag, fin);
  fclose(fin);
  printf("Here is the FLAG: %s\n", flag);
}

int main(void) {
  setbuf(stdin, NULL);
  setbuf(stdout, NULL);
  setbuf(stderr, NULL);

  _Decimal64 x_dd = 0.1dd;
  {
    unsigned long x_ul = 0;
    memcpy(&x_ul, &x_dd, 8);
    printf("hint: %016lX\n", x_ul);
  }

  unsigned long y_ul = 0;
  if (scanf("%lX", &y_ul) != 1) {
    fail("an integer in the hexadecimal format is needed.");
  }

  _Decimal64 y_dd = 0.0dd;
  memcpy(&y_dd, &y_ul, 8);

  if (x_dd != y_dd) {
    fail("their values should be equal.");
  }
  if (memcmp(&x_dd, &y_dd, 8) == 0) {
    fail("their representations should differ.");
  }

  win();
}

🤔

solve

0x318000000000000A