![]() |
|
|
#1794 | |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Quote:
|
|
|
|
|
|
|
#1795 |
|
Aug 2006
10111010110112 Posts |
If you multiply an n digit number by an m digit number, n + m digits will suffice (though the most significant digit may be 0).
|
|
|
|
|
|
#1796 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Okay I think I get the preset stuff, if I just add I get 4+9+6+6 if I have it as is.
Last fiddled with by science_man_88 on 2010-11-29 at 18:54 |
|
|
|
|
|
#1797 |
|
"Forget I exist"
Jul 2009
Dumbassville
100000110000002 Posts |
Code:
answer[#answer-(x*y-1)]=(answer[#answer-(x*y-1)]+n);carry=floor((c[y]*d[x])/10) Code:
[6, 0, 13, 6] -(1*1-1) gives -0, -(2*1-1) and -(1*2-1) give -1,But -(2*2-1) gives -(3) so it skips -2 the place it should go in. Last fiddled with by science_man_88 on 2010-11-29 at 19:40 |
|
|
|
|
|
#1798 |
|
Aug 2006
597910 Posts |
I wouldn't worry about carries; just fix them in the end.
|
|
|
|
|
|
#1799 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
It's not a carry problem it's a placement formula error problem because I should of had a formula to place the 6 in the 2nd from right not the very right.
Last fiddled with by science_man_88 on 2010-11-29 at 19:44 |
|
|
|
|
|
#1800 | |
|
Aug 2006
3·1,993 Posts |
Quote:
|
|
|
|
|
|
|
#1801 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
|
|
|
|
|
|
#1802 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
Got it working for 2 digits I'll check for 3. If it works I'll just need to chop off a 0 on the end.
|
|
|
|
|
|
#1803 |
|
"Forget I exist"
Jul 2009
Dumbassville
26·131 Posts |
|
|
|
|
|
|
#1804 |
|
"Forget I exist"
Jul 2009
Dumbassville
26×131 Posts |
Code:
longmultiply(a,b)= c=eval(Vec(Str(a)));d=eval(Vec(Str(b)));carry=0;answer=vector(length(d)+length(c));forstep(x=#d,1,[-1],forstep(y=#c,1,[-1],n=((c[y]*d[x])+carry)%10;answer[#answer-((#d-x+1)+(#c-y+1)-1)]=(answer[#answer-((#d-x+1)+(#c-y+1)-1)]+n);carry=floor((c[y]*d[x])/10)));forstep(w=#answer,2,-1,answer[w-1]=answer[w-1]+floor(answer[w]/10);answer[w]=answer[w]%10) |
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why do I sometimes see all the <> formatting commands when I quote or edit? | cheesehead | Forum Feedback | 3 | 2013-05-25 12:56 |
| Passing commands to PARI on Windows | James Heinrich | Software | 2 | 2012-05-13 19:19 |
| Ubiquity commands | Mini-Geek | Aliquot Sequences | 1 | 2009-09-22 19:33 |
| 64-bit Pari? | CRGreathouse | Software | 2 | 2009-03-13 04:22 |
| Are these commands correct? | jasong | Linux | 2 | 2007-10-18 23:40 |