Check nil result from C in mjs

Is there a simple way, to send null value (no value) form C code to mjs in double variable? i.e. ffi(‘double read_val(void)’)

my ideas is:

  1. send negative value (-1.0) and check that in mjs: if (val >= 0.0){ do_something_useful(); }
  2. send NaN and check it mjs - how?
  3. may be using pointers? where NULL pointer means no value (null, nil, etc).
  4. or some other constant e.g. -infinity?

best, if checking will look simple, like ‘if (val) { do_something_useful(); }’

1 - you can send an out of bounds value.
2 - in C

double do_double(int i) {
  return i >= 0 ? (double) i : strtod("NAN", NULL);
}

in ‘init.js’

let do_double = ffi('double do_double(int)');

let val = do_double(-1);
print('do_double(-1):', isNaN(val) ? 'NaN' : val);
val = do_double(1);
print('do_double(1):', isNaN(val) ? 'NaN' : val);