This code, which is used to setup a component, produces a compiler warning:
[DCC Warning] Unit1.pas(742): W1024 Combining signed and unsigned types - widened both operands
var
iPrecision: cardinal;
iRadius: cardinal;
iActive: boolean;
iInProximity: boolean;
iPrecision := Max(50, 100 - (3 + 2 * ord(iActive and iInProximity)) * iRadius);
Can this be typecast somehow to prevent a compiler warning?
In your case, ord()
returns an integer
, so needs to be explicitely type-casted to cardinal
, by changing ord()
into cardinal()
as such:
iPrecision := Max(50, 100 - (3 + 2 * cardinal(iActive and iInProximity)) * iRadius);
You will get rid of the warning, and your code will be almost the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With