Rounding off to the ceiling or floor value in R Programming – trunc() Function Last Updated : 01 Jun, 2020 Improve Improve Like Article Like Save Share Report trunc() function in R Language is used to return the largest integer that is smaller than or equal to x (i.e : rounds downs the nearest integer). trunc() function behaves as a ceiling function for negative number and floor function for positive number. Syntax: trunc(x) Parameter: x: Numeric value to be rounded off Example 1: # R program to calculate trunc value # Using trunc() method answer1 <- trunc(3.4) answer2 <- trunc(-3.4) answer3 <- trunc(3.6) answer4 <- trunc(-3.6) print(answer1) print(answer2) print(answer3) print(answer4) Output: 3 -3 3 -3 Example 2: # R program to calculate trunc value # Using trunc() method answer1 <- trunc(c(1.5, 2.6, -3, -3.4)) print(answer1) Output: 1 2 -3 -3 Like Article Suggest improvement Next Rounding off a value to specific digits in R Programming - round() Function Share your thoughts in the comments Add Your Comment Please Login to comment...