free software resistance

 the cost of computing freedom is eternal vigilance

### more075.py *original date:* aug 2012 *orginally posted:* sep 2024 all the files from 2012 say theyre from august- i suspect this is the date of a file transfer rather than the date they were created, some may actually be from 2012 though. i was interested in bignum operations using basic, this was my integer addition demo, now as python code: ``` # long addition demo; adds two 75 digit numbers # 2005 mennonite # 2009 ported to python # public domain import time, random, curses def more075(mor75): global osum, n1, n2 df = 1 n1, n2="", "" tens, b, bb=0, "0", "0" osum="" curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_BLACK) blu=curses.color_pair(1) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK) grn=curses.color_pair(2) curses.init_pair(4, curses.COLOR_RED, curses.COLOR_BLACK) red=curses.color_pair(4) curses.init_pair(5, curses.COLOR_MAGENTA, curses.COLOR_BLACK) mgn=curses.color_pair(5) curses.init_pair(7, curses.COLOR_WHITE, curses.COLOR_BLACK) wht=curses.color_pair(7) curses.init_pair(3, curses.COLOR_RED, curses.COLOR_WHITE) redw=curses.color_pair(3) curses.init_pair(8, curses.COLOR_BLUE, curses.COLOR_WHITE) bluw=curses.color_pair(8) curses.curs_set(0) # create two random 75 digit numbers mor75.addstr(2,5,"hello") ; mor75.refresh() for q in range(75): n = random.randint(0,9) # random digit 0 through 9 nn = random.randint(0,9) # ditto n1 = n1 + str(n) n2 = n2 + str(nn) mor75.addstr(1,0,chr(32)*2 + n1, red) ; mor75.refresh() mor75.addstr(2,0,chr(32)*2 + n2, blu) ; mor75.refresh() mor75.addstr(3,0,"+"+chr(32)+"_"*75,wht) ; mor75.refresh() n1 = "0" + n1 n2 = "0" + n2 for xx in range(len(n1)): x=len(n1)-xx # this does no calculating. for show only. x1 = x + 1 try: b = n1[x1-2] mor75.addstr(1, x1-1, b, redw) ; mor75.refresh() except: pass if df: time.sleep(0.25) try: bb = n2[x1-2] mor75.addstr(2, x1-1, bb, bluw) ; mor75.refresh() except: pass if df: time.sleep(0.25) ones1 = int(n1[x-1]) # digit ones2 = int(n2[x-1]) # digit somesum = str(ones1 + ones2 + int(tens)) # add ones, carry if applicable onesum = int(somesum[len(somesum)-1]) # rightmost digit of (ones1 + ones2) # create tens variable (for carrying) if len(somesum) > 1: tens = int(somesum[:len(somesum)-1]) # all digits but one on right mor75.addstr(0, x-1, str(tens), grn) ; mor75.refresh() else: tens = 0 # don't carry other digit(s) if (x == 1 and onesum == 0) == 0: mor75.addstr(4, x, str(onesum),mgn) ; mor75.refresh() osum=str(onesum)+osum # this does no calculating. for show only. if df: time.sleep(.25) mor75.addstr(1, x1-1, b, red) ; mor75.refresh() mor75.addstr(2, x1-1, bb, blu) ; mor75.refresh() if df: time.sleep(2) curses.wrapper(more075) print " "+n1[1:] print " "+n2[1:] print "+" print (" "+osum)[-76:] ``` license: 0-clause bsd ``` # 2005, 2009 mn # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ``` => https://freesoftwareresistance.neocities.org