Values which have type INTEGER in functions.yaml should be handled as type numeric, and not type integer, in R. This is so that we can support values greater than $2^{31}-1$.
This change needs to be done in:
[ ] Stimulus code generator
[x] On the R side, use as.numeric instead of as.integer
[ ] On the C side, retrieve value as REAL (i.e. double type) instead of INTEGER, then converted to igraph_integer_t
[x] When converting from a double to igraph_integer_t, we need to check that the following holds and throw an error otherwise:
[ ] The value fits in an igraph_integer_t, i.e. IGRAPH_INTEGER_MIN <= value && value <= IGRAPH_INTEGER_MAX.
[ ] The integer value was exactly representable in a double to start with. Check that the value is no greater than IGRAPH_MAX_EXACT_REAL. This constant is currently internal, found in cigraph/src/math/safe_intop.h.
[ ] Do the same as above for the hand-written code in rinterface_extra.c. Pay attention that for some functions, only the R code, or only the C code is auto-generated, but not both. Thus the update needs to be done simultaneously for the auto-generated code and the hand-written one.
I have already updated most of the hand-written code where possible, but I did not add overflow checks for the double -> igraph_integer_t conversion. This should be done as well, as the last step.
@krlmlr It seems to me that the parts which are essential for a 2.0 release are done. I'm removing this from the upgrade milestone. Re-add it if you disagree.
Values which have type
INTEGER
in functions.yaml should be handled as typenumeric
, and not typeinteger
, in R. This is so that we can support values greater than $2^{31}-1$.This change needs to be done in:
as.numeric
instead ofas.integer
REAL
(i.e.double
type) instead ofINTEGER
, then converted toigraph_integer_t
double
toigraph_integer_t
, we need to check that the following holds and throw an error otherwise:igraph_integer_t
, i.e.IGRAPH_INTEGER_MIN <= value && value <= IGRAPH_INTEGER_MAX
.double
to start with. Check that the value is no greater thanIGRAPH_MAX_EXACT_REAL
. This constant is currently internal, found incigraph/src/math/safe_intop.h
.rinterface_extra.c
. Pay attention that for some functions, only the R code, or only the C code is auto-generated, but not both. Thus the update needs to be done simultaneously for the auto-generated code and the hand-written one.I have already updated most of the hand-written code where possible, but I did not add overflow checks for the
double
->igraph_integer_t
conversion. This should be done as well, as the last step.