[fpc-pascal] C# translatation

Sven Barth pascaldragon at googlemail.com
Sun Jan 8 13:54:40 CET 2017


On 08.01.2017 12:55, Ryan Joseph wrote:
> 
>> On Jan 8, 2017, at 5:46 PM, Sven Barth <pascaldragon at googlemail.com> wrote:
>>
>>> 2) % is the mod operator in pascal right? So what is the modular assignment %=? num = num mod repeat?
>>>
>>> p[x] = permutation[x%256];
>>>
>>> if (repeat > 0) num %= repeat;
>>
>> Correct for both.
> 
> 
> why am I getting this error? Operator is not overloaded: "Double" mod “LongInt”. Mod can’t be used with double and integers like in C?
> 
> repeatValue: integer;
> x, y, z: double;
> 
> 	if (repeatValue > 0) then			
> 		begin
> 			x := x mod repeatValue;
> 			y := y mod repeatValue;
> 			z := z mod repeatValue;
> 		end;

Ehm, right. Add the Math unit, it contains an operator overload for
floating points. Alternatively you can use (also from the Math unit) the
FMod() function.

Regards,
Sven



More information about the fpc-pascal mailing list