[Question]
  [
This is a simple task. Given a positive or negative real number, round it to the next whole integer closer to zero.
# The challenge
* Take input through any reasonable form (stdin, function, etc.) of one positive or negative real number.
* Round this number "towards zero" - this means if it is positive you will round down, and if it is negative you will round up.
* Return the number or output it to the console.
# Test cases
```
 1.1   =>  1
 1.9   =>  1
-1.1   => -1
 500.4 =>  500
-283.5 => -283
 50    =>  50
-50    => -50
```
# Rules
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so least score in bytes wins.
* Be mindful of the [standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default).
Have fun!
more Jimmy challenges coming soon
  
[Answer]
# [Python 3](https://docs.python.org/3/), 3 bytes
```
int
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPzOv5H9BEZDUSNPQNTI20TMzNzfX1PwPAA "Python 3 – Try It Online")
Truncates the digits after the decimal point.
*NOTE: This is a trivial answer. Please take a look at the other answers before upvoting*
[Answer]
# [Python 2](https://docs.python.org/2/), 3 bytes
```
int
```
[Try it online!](https://tio.run/##LY1BCoAgFETXeYq/LPh91Aoi8CTmVnKjIm46vWm6ejO8gYlvfoKXxaq7OJ@LDQkcBnAetBYkEARxg6DXv6yjHZzTjtDQrTw3OqpvHAvibTB8rz@MudgUU32rT2BntyAEpVpg5QM "Python 2 – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 1 [byte](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
r
```
A full program (as a monadic Link it returns a list of length one).
**[Try it online!](https://tio.run/##y0rNyan8/7/o////uuZ6lgA "Jelly – Try It Online")**
### How?
```
r - Main Link: number, X           e.g. -7.999
r - inclusive range between left (X) and right (X) (implicit cast to integer of inputs)
  -  = [int(X):int(X)] = [int(X)]       [-7]
  - implicit (smashing) print            -7
```
[Answer]
# [Perl 5](https://www.perl.org/) `-p056l15`, 2 bytes
```
<>
```
[Try it online!](https://tio.run/##K0gtyjH9/9/G7v9/Ez0Ts3/5BSWZ@XnF/3ULDEzNcgxNAQ "Perl 5 – Try It Online")
### How does that work?
```
-056   # (CLI) Make "." the input record separator
-l15   # (CLI) Make "\n" the output record separator
       # (otherwise it would use the input separator)
-p     # (CLI) Implicitly read $_ from STDIN
<>     # Read the second input field and do nothing with it
-p     # (CLI) Output $_ to STDOUT
```
Or if you prefer a more traditional answer:
### [Perl 5](https://www.perl.org/), 6 bytes
```
$_=int
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3jYzr@T/f10jPdN/@QUlmfl5xf91CwA "Perl 5 – Try It Online")
[Answer]
# [Labyrinth](https://github.com/m-ender/labyrinth) & [Hexagony](https://github.com/m-ender/hexagony), 3 bytes
Thanks to FryAmTheEggman for pointing out I'd written some Hexagony!
```
?!@
```
**[Try it online!](https://tio.run/##y0lMqizKzCvJ@P/fXtHh/39dcz1LAA "Labyrinth – Try It Online")** & **[Try it online!](https://tio.run/##y0itSEzPz6v8/99e0eH/f11zPUsA "Hexagony – Try It Online")**
### How?
Labyrinth and Hexagony will both tell you as early as possible!...
```
? - read and discard from STDIN until a digit, a - or a + is found. Then read as many characters as possible to form a valid (signed) decimal integer and push its value
! - pop a value and write its decimal representation to STDOUT
@ - exit the labyrinth
```
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 26 bytes
```
,[.+++++[->+++++<]>+[,>]<]
```
[Try it online!](https://tio.run/##SypKzMxLK03O/v9fJ1pPGwSide3AtE2snXa0jl2sTez//7pGBnqmAA "brainfuck – Try It Online")
Outputs with a trailing `.` if the number was a decimal
There's not much specual golfing wise, except that instead of subtracting 46 to check if a character is a `.`, I add 5 and multiply by 5 to get 255, then add one more to roll over to zero. Subtracting 3, multiplying by 6 and subtracting 2 is the [same bytecount](https://tio.run/##SypKzMxLK03O/v9fJ1pPV1c3WtdOGwxsYu2APB27WJvY//91jQz0TAE)
[Answer]
## C (tcc), ~~39~~ ~~21~~ 10 bytes
I was actually quite surprised nobody thought of using C.
```
f(float i){}
```
This is not an identity function as it seems to be. The implicit int type of the f function trunctuates the floating-point.
[TIO](https://tio.run/##S9YtSU7@/z9NIy0nP7FEIVOzuvZ/bmJmnoamQjUXZ0FRZl5JmoaSaoqSjkKahqmeiaamNVftfwA)
Less likely to trick people but has a shorter byte length:
```
f(int i){}
```
[TIO](https://tio.run/##S9YtSU7@/z9NIzOvRCFTs7r2f25iZp6GpkI1F2dBEVAwTUNJNUVJRyFNw1TPRFPTmqv2PwA)
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 4 bytes
```
*+|0
```
Anonymous function.
[Try it online!](https://tio.run/##K0gtyjH7n1upoJZm@19Lu8bgv7VCcSKIq6FrpGeq@R8A "Perl 6 – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 11 bytes
```
proc &:to_i
```
I picked this one because it distinguishes itself from the lambdas that us Ruby golfers typically use (thankfully, it had the same bytecount as the "traditional" solution):
```
->n{n.to_i}
```
[Try it online!](https://tio.run/##KypNqvyfZvu/oCg/WUHNqiQ/PvN/gUJatKGeYSwXiKELZxnH/gcA "Ruby – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 6 bytes
```
**<.@|
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/tbRs9Bxq/mtypSZn5CsYKtgqpCkY6hkqKChAROIhQvFgMYiQqYEBWAxI65lAVRlZGEPUARl6pnCFUHUI00BssDpTg/8A "J – Try It Online")
Sign `*` times `*` the round down `<.` of the absolute value `@|`
[Answer]
# [R](https://www.r-project.org/), ~~13~~ 5 bytes
Thanks Robin Ryder
```
trunc
```
[Try it online!](https://tio.run/##K/qfpmD7v6SoNC/5f5qGoZ6hJheIsgRRukZ6Fpr/AQ "R – Try It Online")
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 5 bytes
```
\..*
```
[Try it online!](https://tio.run/##K0otycxL/P8/Rk9Pi@v/f0M9Qy5dEGFqYKBnwqVrZGGsZwrkcOmaGgAA "Retina 0.8.2 – Try It Online") Link includes test cases.
[Answer]
# JavaScript, 6 bytes
```
x=>x^0
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNEtLshMSS3Kzc/LTq38n2b7v8LWriLO4H9BUWZeiUaahoKhnqGCgqamtYK@voKCIRdMXBdZXBchrmBqYKBnAlMP5CB0GFkY65nCdAA5yHoUEHaYImlBlgByuP4DCQA "JavaScript (SpiderMonkey) – Try It Online")
---
# JavaScript, 8 bytes
Using built in is 2 bytes longer...
```
parseInt
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNEtLshMSS3Kzc/LTq38n2b7vyCxqDjVM6/kf0FRZl6JRpqGgqGeoYKCpqa1gr6@goIhF0xcF1lcFyGuYGpgoGcCUw/kIHQYWRjrmcJ0ADnIehQQdpgiaUGWAHK4/gMJAA "JavaScript (SpiderMonkey) – Try It Online")
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), 15 bytes 9 bytes
```
s->(int)s
```
[Try it online!](https://tio.run/##NY7NasMwEITP1lMMgYAEtkjaBkpNcs@hpxxLKaotBaW2bCwlIQQ/u7vyDwhp9tPuzF7UTWVNq92l/Bva629lCxSV8h6fyjo8GWBd0J1RhcYxliOA4aZqVIAXObGe0eWDCjR9hMUeg88OnBqFH3LGktl5brk1tkRN/vwUOuvOX99Q3dmLJ0uS0ZZAobz2ZOT0HQuL/wm2cmvSqLKokDKQ3m028m3GL@@vcmcWHjsiJUVvn8eMpsO8f4z5wccUJ6aE08MHXcvmGmRL64Vq2VPSYK0CX60N9gesy1U6GaSw0vBRCiFiRM/o9MM/ "Java (OpenJDK 8) – Try It Online")
thanks to @kevin-cruijssen
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), 3 bytes
```
`i$
```
[Try it online!](https://tio.run/##y9bNz/7/P80qIVPlf5qCoZ6hgi6IMDIw0DMxVdA1MzXXs/wPAA "K (oK) – Try It Online")
[Answer]
# Excel, 10 bytes
```
=TRUNC(A1)
```
`TRUNC` truncates a number to an integer by removing the fractional part of the number.
[Answer]
# [Whitespace](https://web.archive.org/web/20150618184706/http://compsoc.dur.ac.uk/whitespace/tutorial.php) (with [vii5ard compiler](http://vii5ard.github.io/whitespace/)), ~~18~~ 17 bytes
```
[S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve_input][T  N
S T _Print_as_integer]
```
Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.  
`[..._some_action]` added as explanation only.
[Try it online.](http://vii5ard.github.io/whitespace/) You'll have to copy-paste the code yourself (note that SE converts the tabs to a bunch of spaces!) in order to run the code at the online Whitespace-compiler vii5ard. When clicking run, it will ask for an input (i.e. `-283.5`), and after clicking enter it will continue and output `-283`.
**Explanation in pseudo-code:**
```
Integer i = STDIN as integer
Print i as integer
```
Whitespace can only use I/O as integers or single characters, so in this case, the input is read as integer and all other subsequent characters are ignored. I.e. `-283.5` or `-283abc5` would both be input (and thus output) as `-283`.
Unfortunately this above doesn't work on [TIO](https://tio.run/#whitespace) for two reasons (all Whitespace compilers are slightly different..):
1. It will give a `no parse` error when we try to read an input as integer, which isn't an a valid integer. So, instead we'll read one character at a time, and stop (with an error) as soon as we've encountered the `.` or there is no more input (i.e. `50`/`-50`).
2. In the vii5ard compiler it's also possible to push 0 with just `SSN`, whereas on TIO it requires an additional `S` or `T`: `SSSN`/`SSTN`. The first `S` is *Enable Stack Manipulation*; the second `S` is *Push what follows as integer*; the third `S`/`T` is positive/negative respectively; and any `S`/`T` after that (followed by an `N`) is the number we want to push in binary, where `S=0` and `T=1`. For integer 0 this binary part doesn't matter, since it's 0 by default. But on TIO we'd still have to specify the positive/negative, and with most other Whitespace compilers like vii5ard not.
# Whitespace (with [TIO compiler](https://tio.run/#whitespace)), 48 bytes
```
[N
S S N
_Create_Label_LOOP][S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   S _Read_STDIN_as_character][T   T   T   _Retrieve_input][S N
S _Duplicate_input][S S S T S T T   T   S N
_Push_46_.][T   S S T   _Subtract][N
T   S S N
_If_0_Jump_to_Label_EXIT][T N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP]
```
Letters `S` (space), `T` (tab), and `N` (new-line) added as highlighting only.  
`[..._some_action]` added as explanation only.
[Try it online](https://tio.run/##K8/ILEktLkhMTv3/n0tBAYiAmEuBk4tTgZOTE8xXgDI5FcDCQAZYIRfX//@6RhbGeqYA) (with raw spaces, tabs and new-lines only).
**Explanation in pseudo-code:**
```
Start LOOP:
  Character c = STDIN as character
  If(c == '.'):
    Exit program
  Print c as character
  Go to the next iteration of LOOP
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 3 bytes
```
→…0
```
[Try it online!](https://tio.run/##yygtzv7//1HbpEcNywz@//@va6xnDAA "Husk – Try It Online")
Takes a range `…` from 0 toward the input, then gets its last element `→`.
For a positive input this goes like `3.3; [0,1,2,3]; 3`.
For a negative input this goes like `-3.3; [0,-1,-2,-3]; -3`.
[Answer]
# [ReRegex](https://github.com/TehFlaminTaco/ReRegex), 12 bytes
```
\..+//#input
```
[Try it online!](https://tio.run/##K0otSk1Prfj/P0ZPT1tfXzkzr6C05P9/XRNTY1MgMjbRMzUBUqZAvokxAA "ReRegex – Try It Online")
ReRegex is a programming language which matches and replaces over and over until there are no matches.
```
MATCH
    \.                                      The literal period/full stop char
    .+                                      Followed by one or more characters
REPLACE
    (nothing)                               Equivalent to removing the input
STRING TO REPEATEDLY MATCH/REPLACE UNTIL THERE ARE NO MATCHES
    #input                                  The input
```
[Answer]
# [Aheui (esotope)](https://github.com/aheui/pyaheui), 9 bytes
```
방망희
```
[Try it online!](https://tio.run/##S8xILc38///1hpWvl899O3fN//@6hgamehYA "Aheui (esotope) – Try It Online")
Basic idea from that of triangular answer (or any other languages takes numeric input as integer). 
Fun fact. `방망희`(pronounced `bang-mang-heui`(`a` of `ark`)) sounds almost same as `방망이`(pronounced `bang-mang-i`(`a` of `ark`, `i` sounds like `E`), which means bat.
### How does it works?
`방` takes number as integer.
`망` prints value as number.
`희` terminates program.
[Answer]
# [Red](http://www.red-lang.org), 4 bytes
```
to 1
```
[Try it online!](https://tio.run/##K0pN@R@UmhIdy1VQlJlX8r8kX8Hwv66xnvl/AA "Red – Try It Online")
Just converts the float to an integer (conversion by prototype) 
[Answer]
# [Zsh](https://www.zsh.org/), 10 bytes
```
<<<$[0^$1]
```
`xor` with 0. I came across this during [another challenge recently](https://codegolf.stackexchange.com/questions/88926/a-square-of-text/190215#190215).
[Try it online!](https://tio.run/##qyrO@F@ekZmTqlCUmpiikJOZl2qtkJLPVZxaoqCrq6ACEvhvY2OjEm0Qp2IY@z8lH8g34DLQs@TSBRGGIAaYMDbSszQ24QIA "Zsh – Try It Online")
Does not work in Bash or POSIX sh (dash).
[Answer]
# [V (vim)](https://github.com/DJMcMayhem/V), 4 bytes
```
Á.#D
```
[Try it online!](https://tio.run/##K/v//3CjnrLL///GeoYmAA "V (vim) – Try It Online")
Thanks [@DJMcMayhem](https://codegolf.stackexchange.com/users/31716/djmcmayhem), 1 byte saved.
[Answer]
## [GNU sed](https://www.gnu.org/software/sed/), 8 bytes
```
s:\..*::
```
[Try it online!](https://tio.run/##K05N@f@/2CpGT0/Lyur/f0M9Qy5dEGFqYKBnwqVrZGGsZwrkcOmaGgAA)
GNU sed has no concept of numbers. The code removes all text after and including the dot.
[Answer]
## [Keg](https://github.com/JonoCode9374/Keg), ~~19~~ ~~17~~ 13 bytes
This outputs some trailing unprintable characters. Also, this exits with an error. (Now we need reversed input!)
```
?'(:\.>')"([,
```
[Answer]
# ><>, 6 bytes
```
:1%-n;
```
[Try it online!](https://tio.run/##S8sszvj/38pQVTfP@v///7plCoZ6hgA)
Assuming the input is pushed onto the stack. The language specification allowed doing so:
> 
> While parsing numbers is not very hard, it makes for slow and possibly glitchy programs. Most programs requiring number input reads it from the stack at program start. This is done with an interpreter that supports pre-populating the stack with values.
> 
> 
> 
**Explanation:**
```
:      Duplicated the input
 1%    Take the fractional part
   -   The original input minus the fractional part, results in the integer part
    n  Output as a number
     ; Terminates
```
If error is allowed:
# ><>, 5 bytes
```
:1%-n
```
[Try it online!](https://tio.run/##S8sszvj/38pQVTfv////umUKhnqGAA)
The `n` command at the end **pops** and outputs the top of the stack. Then, the IP returns to the first character(because the code is laid out in a torus), and reached a "duplicate" command when the stack is empty. Thus, it errors and terminates.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 4 bytes
```
←x'.
```
[Try it online!](https://tio.run/##yygtzv6f@6ip8f@jtgkV6nr///@PVjLUM1TSUdKFUKYGBnomIK6RhbGeKVgAxAOSsQA "Husk – Try It Online") Splits the string on `'.'` and takes the first segment.
[Answer]
# Intel 8087 FPU machine code, 9 bytes
```
00000000: d92e 0701 d9fc c37f 0f                 .........
```
Listing:
```
D9 2E 0107      FLDCW   CW_RNDDN    ; set FPU CW for truncate (floor) rounding mode 
D9 FC           FRNDINT             ; ST = ROUND_TO_ZERO( ST ) 
C3              RET                 ; return to caller 
    CW_RNDDN    DW  0F7FH           ; control word to round down 
```
Callable function, input is in `ST(0)`, output to `ST(0)`.
The 8087 must first be put into round towards zero mode by setting the control word (`0F7FH`). Rounding towards zero would then take place.
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 5 bytes
```
a//:1
```
[Try it online!](https://tio.run/##K8gs@P8/UV/fyvD///@6hkZ6RiYA "Pip – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 8 bytes
```
truncate
```
[Try it online!](https://tio.run/##y0gszk7NyfmfZhvzv6SoNC85sST1f25iZp5tQVFmXomCikJuYoFCmkK0rqmekY6pjoGOoZ5F7P9/yWk5ienF/3WTCwoA "Haskell – Try It Online")
A built-in that truncates the non-integer part of the number.
]