can someone tell me what i did wrong

-3

It keeps saying

Cannot implicitly convert type 'long' to 'int'. An explicit conversion exists (are you missing a cast?)

int lVar10 = 0x7a69;
int uVar12 = lVar10 * 0x1a3 + 0x181d;
lVar10 = uVar12 + ((uVar12 & 0xffffffff) / 0x7262) * -0x7262;
c++
visual-studio
casting
asked on Stack Overflow Aug 15, 2020 by TechnoCave778 • edited Aug 15, 2020 by Remy Lebeau

3 Answers

1

In short, the numbers you are trying to operate are bigger than the highest possible int value, specifically at the row

lVar10 = uVar12 + ((uVar12 & 0xffffffff) / 0x7262) * -0x7262;

In decimal that number is 2147483647 = 2^31 - 1. Since you are using hexa to represent numbers (with the prefix 0x), the 0xffffffff alone is already bigger than the highest integer.

So you could fix this by declaring lVar10 and lVar12 as long.

answered on Stack Overflow Aug 15, 2020 by Rodrigo Boos
0

You should cast the variables to a long. Adding (long) after the = in the third line should solve it.

Edit:

Also, you could just declare the variable lVar10 and uVar12 as long in the first place.

answered on Stack Overflow Aug 15, 2020 by JeroSquartini • edited Aug 15, 2020 by JeroSquartini
0

You are trying to store a non-integer into an integer variable.

The variable named lVar10 can be assigned integers. For example, values like -3, -2, -1, 0, 1, 2, 3.

answered on Stack Overflow Aug 15, 2020 by Jonah Murrey • edited Aug 15, 2020 by eldesgraciado

User contributions licensed under CC BY-SA 3.0