0

Here's a very surprising bug, which I'm experiencing in R version 4.0.1 on linux.

value = (18-1.8)/18*100
value
#> [1] 90

base::cut(value, right = FALSE, breaks = c(-Inf, 0, 50, 75, 90, 100, Inf))
#> [1] [75,90)
#> Levels: [-Inf,0) [0,50) [50,75) [75,90) [90,100) [100, Inf)

Is this bug documented ? Or am I getting this wrong and this is somehow expected behavior ?

nassimhddd
  • 8,340
  • 1
  • 29
  • 44
  • 2
    I am guessing 90 is not 90. https://stackoverflow.com/q/9508518/680068 , Try: `base::cut(90L, right = FALSE, breaks = c(-Inf, 0, 50, 75, 90, 100, Inf))`, notice L, it makes it an integer with no decimals. – zx8754 Jun 03 '21 at 08:31
  • 2
    to confirm comment by @zx8754 : `(18-1.8)/18*100 == 90L` is `FALSE` – Waldi Jun 03 '21 at 08:35

0 Answers0