A conversion round trip that loses amounts

A billing analyst tests whether converting monetary adjustments to integers and then back to doubles preserves the original dollar amounts. The following code runs in base R:


R
original <- c(14.8, -14.8)
saved <- as.integer(original)
restored <- as.double(saved)
alternative <- c(14.2, -14.2)


The function identical(x, y) returns TRUE when the objects match exactly in values, types, and attributes; otherwise, it returns FALSE.


Complete the audit statements. Enter the first two answers as exact integers, the type name without quotation marks, and the final two answers as TRUE or FALSE.


The first amount in saved, in dollars, is , and the second amount, in dollars, is .


The result of typeof(restored) is .


The result of identical(restored, original) is .


The result of identical(as.integer(alternative), saved) is .

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More R Data Types Questions: