Page 1 sur 1

Syntax Python: x // y floored quotient of x and y

Publié : sam. févr. 16, 2019 10:01 pm
par compsystems
Hello, I am testing the syntax of python on xcas

According to https://docs.python.org/3.7/library/std ... pesnumeric

Says
Also referred to as integer division. The resultant value is a whole integer, though the result’s type is not necessarily int. The result is always rounded towards minus infinity: 1//2 is 0, (-1)//2 is -1, 1//(-2) is -1, and (-1)//(-2) is 0.

xcas have to emulate floored quotient =)

https://en.wikipedia.org/wiki/Modulo_operation

Re: Syntax Python: x // y floored quotient of x and y

Publié : lun. févr. 18, 2019 4:41 pm
par parisse
It does in Python compat mode, at least for positive values of b (I don't really care of negative values of b).

Re: Syntax Python: x // y floored quotient of x and y

Publié : lun. févr. 18, 2019 8:19 pm
par compsystems
// is interpreted as iquo cmd,

I think it is important to define a new function flooredMod() on xCAS, which include negative values of b and decimal numbers

pyhton
-5.5//3 returns -2


PD: to emulate output, on the xor operator
Python:
True^True returns False
Xcas Syntax Python
python_compat(2) and (^==Xor)
True^True returns 0 => false =)

Re: Syntax Python: x // y floored quotient of x and y

Publié : mar. févr. 19, 2019 8:12 am
par parisse
fmod(a,b) returns a mod b for floats.