[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 21 KB, 200x225, 1284689657920.jpg [View same] [iqdb] [saucenao] [google]
3092919 No.3092919 [Reply] [Original]

Why does (-1 % 79) equal -1 and not 79?

>> No.3092982

% is the modulus operator, because -1/79 cannot be simplified into a whole number, it becomes 0/79 with remainder of -1, and the modulus operator returns the remainder of the division of the two terms entered

-With pleasure, a programmer without a life.

>> No.3093054

There are different definitions of mod. Another one is for example<div class="math">a~\mathrm{mod_1}~b := a - \left\lfloor \frac ab \right\rfloor b</div><div class="math">-1~\mathrm{mod_1}~79 = -1 - \left\lfloor -\frac1{79} \right\rfloor 79=-1 - (-1)\cdot 79=78</div>