Lightning Talk: Finding the Average of 2 Integers - Tomer Vromen - CppCon 2022

preview_player
Показать описание
---

Lightning Talk: Finding the Average of 2 Integers - Tomer Vromen - CppCon 2022

I'm going to discuss the (a+b)/2 problem - not the midpoint problem (for which Marshal is an expert) but rather the one with a possibly fractional result. It will be a quick taste of the limits of using floating points to represent integers.
---

Tomer Vromen
__

#cppcon #programming #cpp
Рекомендации по теме
Комментарии
Автор

The amount of nuance that goes into relatively simple arithmetic is something else.

matts
Автор

I absolutely adore the lightning talks. Thanks for the video!

ErikSnider
Автор

A double is large enough to hold all 32-bit integers, though. With 64-bit integers, the problem becomes much harder.

LesleyLai
Автор

I loved how he said "No I have three more min's left" ;-) He reminded me of Alexandrescu for a second!!!

elangovv.
Автор

if they have opposite signs then return (a+b)/2, else return a+(b-a)/2.

raymondg
Автор

world: does things
meanwhile, guys in C++:

thebzn
Автор

so the "easy" approach could be to use something like big integer and wrap that into a fixed point number ...

urugulu
Автор

He's looks like C++ deadpool lol
Humor and smarts, nice

dexterman
Автор

My best way ;
Int average (int a, int b)
{
Short* p = (short*)&a
Short *q = (short*)&b
Return *(p) <<16 + *(q+1);
}

__hannibaalbarca__
Автор

People just write code, and it works when they test it, but if you really squint at every line, the code is usually filled with those numeric errors. This means that contrary to popular belief, very few functions can be reused in other contexts without a lot of extra work. Just the sad reality of programming.

piotrarturklos