Multiplying Big-Ints in scheme-racket

I've implemented a "big-int" in scheme as a list, so the first element is the sign of the number (+ or -) and the following are the value of the number itself, first the ones, then the tens etc.

For example: (+ 0 0 1) is for 100, (- 9 2 3 1) is for -1329 etc.

What I need now is to implement addition, subtraction and multiplication for big-ints implemented in this manner. I've done addition and subtraction, can someone help me with multiplication, please?

Answers


Break the problem up into smaller pieces. First, write a function that multiplies a Big-int by a single digit. Then, extend this (using Greg Hewgill's hint that you probably know how to do this on paper) to a function that multiplies a Big-int by a list of digits. Finally, wrap this in a function that accepts two Big-ints, strips off the sign, and then calls your previous function.

I strongly suggest that you write test cases for these functions before developing them.


Need Your Help

Getting 2 Tomcat servers comminicating with each other

java tomcat servlets rmi business-logic-layer

I have a Java web application I’m developing for a school project. There’s a requirement to have the presentation tier (servlets/jsp) be deployed to one server and business logic be deployed to ano...

Passing own struct into opengl es 2.0 shader

iphone opengl-es shader opengl-es-lighting

I want to try a lighting example from the book OpenGL ES 2.0 Programming Guide. In the shader they have made two structures.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.