What is the difference between an integer and a double in R, and what does the L suffix do?

Quick Overview

Explain how integers and doubles differ in R and what the L suffix on a number literal does. Tests knowledge of R storage types, typeof versus class, type promotion in arithmetic, integer overflow and the memory trade-off between the two types.

What is the difference between an integer and a double in R, and what does the L suffix do?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

What is the difference between an integer and a double in R, and what does the `L` suffix do? ```hint Check the storage type Compare what `typeof()` and `class()` report for `5` and `5L`, then try a few arithmetic operations that mix the two. ``` ### What a Strong Answer Covers - How each type is stored, and which one a plain number literal creates - What the `L` suffix does and how to check the resulting type - What happens to the type in mixed arithmetic and in division - Practical consequences such as memory use, overflow and exact comparisons ### Follow-up Questions - What does `.Machine$integer.max + 1L` return, and why? - Why does `identical(5L, 5)` return `FALSE` while `5L == 5` returns `TRUE`? - When does the integer type actually matter in a data analysis workflow?

Overview: Explain how integers and doubles differ in R and what the L suffix on a number literal does. Tests knowledge of R storage types, typeof versus class, type promotion in arithmetic, integer overflow and the memory trade-off between the two types.

PracHub logo
General
Nov 25, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

What is the difference between an integer and a double in R, and what does the L suffix do?

What a Strong Answer Covers Guidance

  • How each type is stored, and which one a plain number literal creates
  • What the L suffix does and how to check the resulting type
  • What happens to the type in mixed arithmetic and in division
  • Practical consequences such as memory use, overflow and exact comparisons

Follow-up Questions Guidance

  • What does .Machine$integer.max + 1L return, and why?
  • Why does identical(5L, 5) return FALSE while 5L == 5 returns TRUE ?
  • When does the integer type actually matter in a data analysis workflow?