Get the latest tech news

C++ float-to-int conversion can be undefined behavior


g a float to an int in C++ is undefined behavior when the truncated float does not fit into the destination integer. C++ makes it easy to do this accidentally.

None

Get the Android app

Or read this on Hacker News

Read more on:

Photo of conversion

conversion

Photo of undefined behavior

undefined behavior

Photo of C++ float

C++ float

Related news:

News photo

US achieves world's first end-to-end conversion of biogas to jet fuel

News photo

Everything in C is undefined behavior

News photo

PGIM's Marcus: Seeing More Office-to-Housing Conversion