# How does modulo operation work in terms of the remainder of long division with negative dividends?

I'm trying to figure out how the modulo operation works using long division with negative dividends.

I know that $-1 \bmod 10 = 9$. But I can't figure out why.

For positive dividends, it's relatively straightforward.

$1 \bmod 10$ is the remainder of the long division of $1 ÷ 10$, which is $1$. But when I try to find the remainder of the long division of $-1 ÷ 10$, I get $-1$, not $9$. What am I doing wrong or failing to grasp?

When we divide $a$ by $b$ we can write $a=qb+r$ where $q$ is the quotient and $r$ is the remainder. We usually define $r \in [0,b-1]$ and it looks like you are doing so. In that case we write $-1=-1\cdot 10+9$, so the quotient is $-1$ and the remainder is $9$. You want the largest multiple of $b$ that is less than $a$. In your example that is $-10$, not $0$ as $0 \not \lt -1$
{"ft_lang_label":"__label__en","ft_lang_prob":0.90153545,"math_prob":0.9997174,"size":430,"snap":"2019-51-2020-05","text_gpt3_token_len":121,"char_repetition_ratio":0.12206573,"word_repetition_ratio":0.07594936,"special_character_ratio":0.3116279,"punctuation_ratio":0.12087912,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99997747,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-27T09:39:34Z\",\"WARC-Record-ID\":\"<urn:uuid:5d53cb6b-27bc-4175-9abe-93e519e3c9f6>\",\"Content-Length\":\"133116\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:d273233e-ad47-4ea6-8963-6d8457b3bb9a>\",\"WARC-Concurrent-To\":\"<urn:uuid:16c4ec21-1b03-4281-9d59-e5295e636c49>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://math.stackexchange.com/questions/2922923/how-does-modulo-operation-work-in-terms-of-the-remainder-of-long-division-with-n\",\"WARC-Payload-Digest\":\"sha1:5YCZEHIMMPINSZEJI673QOOIHS5GZNSA\",\"WARC-Block-Digest\":\"sha1:QIMBYHZAHWTCF5QQX4DIIDUPGV4MNQOS\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579251696046.73_warc_CC-MAIN-20200127081933-20200127111933-00495.warc.gz\"}"}