@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 ...
Arbitrarily Big Integer Routines
-
- Posts: 62
- Joined: Nov 02, 2013 14:57
Re: Arbitrarily Big Integer Routines
Try this: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.
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
Re: Arbitrarily Big Integer Routines
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
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.
https://github.com/stephanbrunker/big_integer
https://github.com/stephanbrunker/big_integer
-
- Posts: 231
- Joined: Apr 10, 2010 11:41
- Location: Japan
- Contact:
Re: Arbitrarily Big Integer Routines
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.
Dear integer
Dear srvaldez
Thank you very much for teaching me how to write programs.
I will be getting started with big_integer-master.
Re: Arbitrarily Big Integer Routines
Maybe stack instead string would be faster