There's already one in Javascript, by Leemon Baird:

http://www.leemon.com/crypto/BigInt.js

Bill.

On 5 December 2012 15:19, William Stein <wst...@gmail.com> wrote:
>
> On Dec 3, 2012 2:52 PM, "Bill Hart" <goodwillh...@googlemail.com> wrote:
>>
>> Hi all,
>>
>> I was quite bored over the weekend and decided to try and implement a
>> really, really simple bignum library in C++ (it's 17 years since I
>> wrote a C++ program, so I needed some practice). Consider it a
>> Christmas present for someone who has everything else.
>>
>
> I'd like one in Javascript for Chanukah. :-)
>
>> You can find the result here:
>>
>> https://github.com/wbhart/simple
>>
>> It has a class for arithmetic with unsigned bignums (called nat_t's),
>> which have their own memory management. Obviously you can't represent
>> -ve numbers in this format, so the result of any operation with a
>> negative result is undefined.
>>
>> It also has a class for arithmetic with signed bignums (called
>> znat_t's), which also manage their own memory.
>>
>> The library is quite slow for more than about 30 limbs. But it does
>> surprisingly well for small operands, compared with MPIR, even beating
>> a generic C build for some operations. (No idea why.)
>>
>> Enjoy!
>>
>> Bill.
>>
>> P.S: it has lots of bugs.
>>
>> P.S.S: whilst implementing this library, I found a beautiful algorithm
>> for doing division of bignums (not included in Simple). I will have to
>> think about where I can use that.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "mpir-devel" group.
>> To post to this group, send email to mpir-devel@googlegroups.com.
>> To unsubscribe from this group, send email to
>> mpir-devel+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/mpir-devel?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "mpir-devel" group.
> To post to this group, send email to mpir-devel@googlegroups.com.
> To unsubscribe from this group, send email to
> mpir-devel+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mpir-devel?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"mpir-devel" group.
To post to this group, send email to mpir-devel@googlegroups.com.
To unsubscribe from this group, send email to 
mpir-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/mpir-devel?hl=en.

Reply via email to