You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Neal Richardson (Jira)" <ji...@apache.org> on 2021/09/17 19:14:00 UTC

[jira] [Commented] (ARROW-14028) [R] Cast of NaN to integer should return NA_integer_

    [ https://issues.apache.org/jira/browse/ARROW-14028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17416881#comment-17416881 ] 

Neal Richardson commented on ARROW-14028:
-----------------------------------------

This seems like a C++ issue, right? Or do numpy and others handle this differently from R?

> [R] Cast of NaN to integer should return NA_integer_
> ----------------------------------------------------
>
>                 Key: ARROW-14028
>                 URL: https://issues.apache.org/jira/browse/ARROW-14028
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: R
>            Reporter: Ian Cook
>            Priority: Major
>
> Casting doubleĀ {{NaN}} to integer returns a sentinel value:
> {code:r}
> call_function("cast", Scalar$create(NaN), options = list(to_type = int32(), allow_float_truncate = TRUE))
> #> Scalar
> #> -2147483648
> call_function("cast", Scalar$create(NaN), options = list(to_type = int64(), allow_float_truncate = TRUE))
> #> Scalar
> #> -9223372036854775808{code}
> It would be nice if this would instead return {{NA_integer}}.
> N.B. for some reason this doesn't reproduce in dplyr unless you round-trip it back to double:
> {code:r}
> > Table$create(x = NaN) %>% transmute(as.double(as.integer(x))) %>% pull(1)
> #> [1] -2147483648{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)