Long multiplication: Difference between revisions

Content added Content deleted
m (→‎{{header|Quackery}}: teensy tweak)
Line 4,768: Line 4,768:
In addition to the specified task, we were always encouraged to show our workings.
In addition to the specified task, we were always encouraged to show our workings.


<lang Quackery> [ [] swap witheach
<lang Quackery>( ------------- preamble to task, some i/o related words ------------- )

[ [] swap witheach
[ char 0 -
[ char 0 -
swap join ] ] is $->long ( $ --> L )
swap join ] ] is $->long ( $ --> L )
Line 4,781: Line 4,783:
witheach echo ] is echolong ( L --> )
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
[ [ table
Line 4,803: Line 4,800:
[ dip add add dip [ add nip ] swap ] is addc ( n n c --> n c )
[ dip add add dip [ add nip ] swap ] is addc ( n n c --> n c )


[ zeropad
[ over size
0 temp put
over size -
[] unrot witheach
dup dip
[ dip behead
[ 0 < 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
temp take
addc
addc
Line 4,853: Line 4,857:
timesten ]
timesten ]
drop ] is longmult ( L L --> L )
drop ] is longmult ( L L --> L )



( ------------------------ additional to task ------------------------ )
( ------------------------ additional to task ------------------------ )