Skip to content

Commit e77a951

Browse files
committed
fixed overflow in map
1 parent 0f4e57e commit e77a951

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

api/Common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/* C++ prototypes */
2323
long map(long x, long in_min, long in_max, long out_min, long out_max)
2424
{
25-
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
25+
return (long)((long long)(x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
2626
}
2727

2828
uint16_t makeWord(uint16_t w) { return w; }

0 commit comments

Comments
 (0)