# Rounding and integer math

DevFeed: [Rounding and integer math](<https://devfeed.tech/articles/rounding-and-integer-math-33011.md>)

Original publisher: [Read original article](<https://reactos.org/blogs/rounding-and-integer-math/>)

Published: 2015-05-16T00:00:00Z

Content type: tutorial

Language: en

Sources: [Front Page on ReactOS Website](<https://devfeed.tech/sources/front-page-on-reactos-website.md>)

Topics: [math](<https://devfeed.tech/topics/math.md>), [floating-point](<https://devfeed.tech/topics/floating-point.md>)

Tags: [c](<https://devfeed.tech/tags/c.md>), [floating-point](<https://devfeed.tech/tags/floating-point.md>), [free](<https://devfeed.tech/tags/free.md>), [math](<https://devfeed.tech/tags/math.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [os](<https://devfeed.tech/tags/os.md>), [react](<https://devfeed.tech/tags/react.md>), [reactos](<https://devfeed.tech/tags/reactos.md>), [win32](<https://devfeed.tech/tags/win32.md>), [winapi](<https://devfeed.tech/tags/winapi.md>)

## AI overview

This article examines whether integer arithmetic can reproduce rounding results without using floating-point math. It simplifies the problem to unsigned values and analyzes the formulas for even and odd divisors.

## Source excerpt

It sometimes happens that in your program you need to divide integer values and then round the result. Something like int result = lrint((double)int_a / (double)int_b); But sometimes it is desirable to not use floating point math at all. The question is: Can we do the same calculation with integer math and get exactly the same result? Let's simplify our case, by limiting to unsigned values (for signed values it is very similar, only the formulas get a bit more complex).