Logo

Programming-Idioms

History of Idiom 81 > diff from v22 to v23

Edit summary for version 23 by :
New C implementation by user [D̵̢̛̺̦̝̻̮̟̤̥̘̬̰̮͐̆͋ͯͪ̅ͦͧ̒̅̔ͧ̏͌̓ͯ̅̾ͯ͢O̴̡̱̺͉̪͙̘̰̝̹͗͌ͦͣͮ̐̃ͮͧͣ̚͟͢͠O̸̢̨̩̼͇̯ͨ̾̆ͭ̾̇̎͌͂̍ͫ͌͑̈́͛̈̌ͣM̰̣̖̭̯̥̰̦̣̬ͧͥ́ͣ͛͢͡ ̘͎̞̞͓̗̺̯̭̲͔͕͎̐̐ͧ̍́͞Ȋ̢̲̟̦͚̦͇̞̝͕̈ͧ̇͌͛ͮͭ̽̒̿̂ͮ̌̅͡͡S̵̶̢̻̘̜̲̭̦̖̬̺ͯͪ̑̑͜ͅ ̵̴͕̠͓͎̦̞̜̙̱̦̥̠̰̈ͮͣͪ̊́̚ͅU̦͚̯̗ͪ̔ͯ̍͌́͒́̃̅͊̂́͒́͘P̨̰̬͙̬̑͌ͨͤ̀͊ͦ̔̀̀O̡̨̼͔̙͖̙̻͕̣͍̜͂͌͆̽͂̽͋̊̚͢ͅN̛̝̲̤̺̣̻̜̎̽ͨ͋̿̽ͫ̚ ̜̹̖͖̞̺͈̘͈͈̣͚́ͮ͌̌̇̉ͮͦͤ̆ͣ͒ͨ̓ͪ͋͡͞U͈̣̯͇̘̦̗̥̱͐̐́́͗̇͊͝͡S̴̛͙̹̱͚̲̭̩͉̩̤̫̜͇͉͍̏ͣ͛̐ͥͬͣ̔̌̃́]

Version 22

2016-02-18, 16:58:01

Version 23

2016-02-18, 18:19:05

Idiom #81 Round floating point number to integer

Declare integer y and initialize it with the rounded value of floating point number x .
Ties (when the fractional part of x is exactly .5) must be rounded up (to positive infinity).

Idiom #81 Round floating point number to integer

Declare integer y and initialize it with the rounded value of floating point number x .
Ties (when the fractional part of x is exactly .5) must be rounded up (to positive infinity).

Imports
#include <math.h>
Code
int y = (int)floorf(x + 0.5f);