round in C++
От: vadimcher  
Дата: 29.08.09 17:30
Оценка:
В связи с одним обсуждением в Этюдах мне стало интересно, какой вариант round() народ использует на практике (в math.h есть ceil и floor, но если требуется именно round()). Я сам обычно использую "округление вверх для .5": (int)((double)x + 0.5)). В стандарте C99 round() делает более грамотное округление -- половинчатые числа округляются от нуля, т.е. 0.5->1, -0.5->-1.

Оказалось, что это не такая уж и простая задача. Вот, наткнулся на ветку, в которой народ обсуждает, как это грамотно сделать: http://codingforums.com/showthread.php?t=10827. Особенно понравился последний комментарий, после которого ветку закрыли...

When my browser first loaded this page and I read your post, I really didn't care a whole lot as I was but immediately convinced that you were quite ordinary in terms of intelligence, but when I found out that jkd had posted his message before you had posted yours, I began to realize the maginute of your lack of at birth given gifts. Your post was so unnecessary and stupid that it made me euforic about my IQ-result of 144, which a few days ago I thought to be shamefully low compared to certain idols of mine.

I am but certain that I have written nothing of what you want to hear, but the truth has mysterious ways of deploying itself. Though it could this time be explained by my adrenaline aneurism or my autistic behaviour, I think you should gather all your mental and physical resources and repeatedly attempt to increase thy brain acitivity.


А вот зайца кому, зайца-выбегайца?!
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.