Skip to main content

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

Have fun! more Jimmy challenges coming soon

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.1   => -1
 500.4 =>  500
-283.5 => -283
 50    =>  50
-50    => -50

Rules

Have fun! more Jimmy challenges coming soon

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

Have fun! more Jimmy challenges coming soon

Tweeted twitter.com/StackCodeGolf/status/1164824718270091264
Became Hot Network Question
Source Link
moltarze
  • 2.6k
  • 3
  • 17
  • 29

Round towards zero

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.1   => -1
 500.4 =>  500
-283.5 => -283
 50    =>  50
-50    => -50

Rules

Have fun! more Jimmy challenges coming soon