Arbitrarily Big Integer Routines

User projects written in or related to FreeBASIC.
Posts: 62
Joined: Nov 02, 2013 14:57

Re: Arbitrarily Big Integer Routines

Postby stephanbrunker » Jul 27, 2018 8:53

@ur_naz: Speed is something very difficult to get with FB generally. I made a few crypto implementations and they all are slower than their counterparts. And so that is not what I had in mind as I improved this datatype from terrible to acceptable. The idea was to make an easy access to big integer calculating and I think it cannot be easier than this, which works just like an integer. I am no expert on the inner workings of the FB compiler, but I'd bet that has to do with the string handling. It's the same there: as easy as the STRING is in usage, it is not very fast. I have worked around that as far as I could without to clog the code but the handicap remains. But I don't think any sane full-time programmer tasked to write an performance-critical application will resort to FB anyway. But if you (like me) just write a few lines of code once or twice a year, it is far easier to get into the stuff. I have an application for Android written in Java out there and I have to expand it somewhat - and I know it will be days until I am comfortable again because my last concact with Java was 1 1/2 years ago.

@Makoto WATANABE: I think your question is better asked in the "getting started with Freebasic" section. There are a lot of people out there which are much better in explaining basic input and output operations which have nothing to do with this datatype. There are quite a lot of approaches to this problem, ranging from the input function over inkey up to an Windows GUI ...
Posts: 375
Joined: Feb 01, 2007 16:54
Location: usa

Re: Arbitrarily Big Integer Routines

Postby integer » Jul 27, 2018 12:12

Makoto WATANABE wrote:Dear stephanbrunker

Thanks for your quick reply.
Please excuse my inadequate expressions.
I'd like to enter numbers using "Input" command instead of the command line.
Please teach me a sample program.

Try this:

Code: Select all

#include "biginteger_v28.bas"         '' <-- or what you have named it

dim as string bunchodigits
dim as bigint abignummer

input "enter some decimal digits";bunchodigits
abignummer = cbig(bunchodigits)

print "number as entered from keyboard: ";bunchodigits
print "converted to a bigint                  :";abignummer
print "& squared = ";abignummer*abignummer

    number as entered from keyboard: 123456789876543210123456
    converted to a bigint : +123456789876543210123456
    & squared= +15241578966620942051516341899101137082761383936
Posts: 1848
Joined: Sep 25, 2005 21:54

Re: Arbitrarily Big Integer Routines

Postby srvaldez » Jul 27, 2018 14:24

there should be no need to explicitly call the conversion function, this should work

Code: Select all

dim as bigint abignumber
dim as string s

input "enter a BigInt number ",s

abignumber = s ''automatically casted to Bigint
abignumber = abignumber + abignumber
s = abignumber ''automatically casted to String
Posts: 62
Joined: Nov 02, 2013 14:57

Re: Arbitrarily Big Integer Routines

Postby stephanbrunker » Jul 27, 2018 17:33

I have created a github repository and moved the code there. Because the total of 2000 lines, i have split the code into multiple parts, depending on the tasks they do, like the constructors, conversion functions and so on. I have also created an extensive readme with all the neccessary information.
Posts: 103
Joined: Apr 10, 2010 11:41
Location: Japan

Re: Arbitrarily Big Integer Routines

Postby Makoto WATANABE » Jul 28, 2018 4:21

Dear stephanbrunker
Dear integer
Dear srvaldez

Thank you very much for teaching me how to write programs.
I will be getting started with big_integer-master.
Posts: 46
Joined: Mar 02, 2016 12:44

Re: Arbitrarily Big Integer Routines

Postby ur_naz » Jul 29, 2018 17:43

Maybe stack instead string would be faster

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 2 guests