# SDL: Fixed warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte...

**URL:** <https://discourse.libsdl.org/t/sdl-fixed-warning-c26451-arithmetic-overflow-using-operator-on-a-4-byte-value-and-then-casting-the-result-to-a-8-byte/47683>\
**Category:** SDL Commits\
**Created:** [December 5, 2023, 5:32pm UTC](https://discourse.libsdl.org/t/sdl-fixed-warning-c26451-arithmetic-overflow-using-operator-on-a-4-byte-value-and-then-casting-the-result-to-a-8-byte/47683 "2023-12-05T17:32:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [December 5, 2023, 5:32pm UTC](https://discourse.libsdl.org/t/sdl-fixed-warning-c26451-arithmetic-overflow-using-operator-on-a-4-byte-value-and-then-casting-the-result-to-a-8-byte/47683/1 "2023-12-05T17:32:50Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/69b9d44bdc74ee6ffd7415c73a82040c56789613>

```diff
From 69b9d44bdc74ee6ffd7415c73a82040c56789613 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 4 Dec 2023 20:25:18 -0800
Subject: [PATCH] Fixed warning C26451: Arithmetic overflow: Using operator '-'
 on a 4 byte value and then casting the result to a 8 byte value. Cast the
 value to the wider type before calling operator '-' to avoid overflow (io.2).

---
 src/video/windows/SDL_windowskeyboard.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c
index 06396c603d61..c637710c3993 100644
--- a/src/video/windows/SDL_windowskeyboard.c
+++ b/src/video/windows/SDL_windowskeyboard.c
@@ -1484,7 +1484,7 @@ static void StopDrawToBitmap(HDC hdc, HBITMAP *hhbm)
 static void DrawRect(HDC hdc, int left, int top, int right, int bottom, int pensize)
 {
     /* The case of no pen (PenSize = 0) is automatically taken care of. */
- const int penadjust = (int)SDL_floor(pensize / 2.0f - 0.5f);
+ const int penadjust = (int)SDL_floorf(pensize / 2.0f - 0.5f);
     left += pensize / 2;
     top += pensize / 2;
     right -= penadjust;

```
