Jump to content

Long multiplication: Difference between revisions

m (→‎{{header|Quackery}}: teensy tweak)
Line 4,768:
In addition to the specified task, we were always encouraged to show our workings.
 
<lang Quackery>( ------------- [preamble []to swaptask, witheachsome i/o related words ------------- )
 
[ [] swap witheach
[ char 0 -
swap join ] ] is $->long ( $ --> L )
Line 4,781 ⟶ 4,783:
witheach echo ] is echolong ( L --> )
 
( ------------------------- task starts here ------------------------- )
[ over size
over size -
dup dip
[ 0 < if swap ]
abs times
[ 0 join ] ] is zeropad ( L L --> L L )
 
[ [ table
Line 4,803 ⟶ 4,800:
[ dip add add dip [ add nip ] swap ] is addc ( n n c --> n c )
 
[ zeropadover size
0over tempsize put-
[]dup unrot witheachdip
[ dip0 behead< if swap ]
abs times
[ 0 join ] ] is zeropad ( L L --> L L )
 
[ zeropad ( when adding to numbers of different lengths, )
0 temp put ( leading zeroes are added to make the lengths )
[] unrot witheach ( equal. This is implicit when the calculation )
[ dip behead ( done by hand, and is done by zeropad here. )
temp take
addc
Line 4,853 ⟶ 4,857:
timesten ]
drop ] is longmult ( L L --> L )
 
 
( ------------------------ additional to task ------------------------ )
1,462

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.