Can anybody give me any idea of a new variable tyep. The question is if I need a variable that would hold more than a double tupe variable then what should I do? Is there any easy way in VB6 which will enable me to create this type of variable and do + - * / works on this type of variable?

I know double is a very very wide one which can hold more than I need, but I wonder what should I do if someone needs one that can hold more than that.

Any Ideas please.

_____________________________________________________________________________

Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->

It looks like you're new here. If you want to get involved, click one of these buttons!

- 140.8K All Categories
- 103.6K Programming Languages
- 6.4K Assembler Developer
- 401 Assembly Code Share
- 239 Getting started in assembly
- 4.6K x86 Assembly
- 1.9K Basic
- 97 Qbasic
- 39.9K C and C++
- 5.6K Beginner C/C++
- 330 C/C++ on Linux/Unix
- 450 C/C++ Windows API
- 522 C++ Builder
- 253 C++ Game Development
- 3.3K C++ MFC
- 103 C++.NET
- 404 Visual C++
- 2.9K C#
- 7.9K Delphi and Kylix
- 334 Advanced Delphi
- 360 Delphi beginners
- 4 Haskell
- 9.7K Java
- 56 Enterprise JavaBeans
- 1.3K Java Beginners
- 304 Java Server Pages
- 4.1K Pascal
- 1.3K Perl
- 11 Perl 6
- 2K PHP
- 546 Python
- 37 Ruby
- 4.4K VB.NET
- 258 Advanced VB.Net
- 1.6K VBA
- 20.8K Visual Basic
- 767 Access databases and VB
- 831 Advance Visual Basic
- 1.2K Beginner VB
- 2.6K Game programming
- 315 Console programming
- 90 DirectX Game dev
- 1 Minecraft
- 112 Newbie Game Programmers
- 2 Oculus Rift
- 9K Applications
- 1.8K Computer Graphics
- 279 3D Graphics
- 129 DirectX
- 125 OpenGL
- 740 Computer Hardware
- 9 Cooling & Overclocking
- 3.4K Database & SQL
- 1.1K Access
- 91 ADO Programming
- 288 MySQL
- 358 Oracle
- 440 SQL-Server
- 535 Electronics development
- 1.6K Matlab
- 628 Sound & Music
- 25 DirectSound
- 257 XML Development
- 3.3K Classifieds
- 199 Co-operative Projects
- 198 For sale
- 190 FreeLance Software City
- 1.9K Jobs Available
- 603 Jobs Wanted
- 209 Wanted
- 2.9K Microsoft .NET
- 1.8K ASP.NET
- 1.1K .NET General
- 22 .NET WEB-Services
- 129 .NET WinForms
- 14 .NET XML
- 50 ADO.NET
- 142 C# & VB.NET School Support
- 3.4K Miscellaneous
- 4 Join the Team
- 354 Comments on this site
- 69 Computer Emulators
- 2.1K General programming
- 187 New programming languages
- 621 Off topic board
- 200 Mobile & Wireless
- 72 Android
- 126 Palm Pilot
- 338 Multimedia
- 154 Demo programming
- 184 MP3 programming
- 0 Bash scripts
- 27 Cloud Computing
- 1 Witsbits Go Cloud
- 53 FreeBSD
- 1.7K LINUX programming
- 1 Awk scripting
- 332 Linux Support
- 0 Sed scripting
- 370 MS-DOS
- 0 Shell scripting
- 321 Windows CE & Pocket PC
- 4.1K Windows programming
- 177 COM/DCOM
- 61 Networking And Security
- 17 Windows 2003 Server
- 6 Windows Vista
- 176 Windows XP
- 939 Software Development
- 416 Algorithms
- 68 Object Orientation
- 24 RUP & UML
- 91 Project Management
- 95 Quality & Testing
- 268 Security
- 63 Evil Scripting
- 81 Hacking
- 7.7K WEB-Development
- 1.8K Active Server Pages
- 61 AJAX
- 4 Bootstrap Themes
- 55 CGI Development
- 28 ColdFusion
- 224 Flash development
- 1.4K HTML & WEB-Design
- 1.4K Internet Development
- 131 Mobile Internet & Messaging
- 211 Wireless development
- 2.2K JavaScript
- 37 JQuery
- 304 WEB Servers
- 153 Apache
- 79 IIS
- 150 WEB-Services / SOAP

## Comments

The standard operators will not work on this type, unless you are using VB.NET (or C++, C# etc) where you can overload the * operator (and others).

In VB6 it will look like:

Class BigNumber

-Function Multiply(Takes either a numeral variable or a BigNumber class)

-... other functions like the previous

-Number property (as a string) containing the integer number contained in BigNumber)

To give you an idea of how it will look. To do this with Integer numbers is the easiest. Creating a large double will be a bit more work.

But the biggest problem is that you will have to 'reinvent' all the mathematical operators... For example: You need create an algorithm to add these 'BigNumbers' to eachother. After that, to create the multiply operator, say for the formula 25 x BigNumber1, you will need to call the Addition 25 times with BigNumber1 as parameter.

Greets...

Richard

Like should it be ok if I seperate the big number into small parts e.g.

12345679.....123456789 into

1234 5678 9... 1234 5678 9012

and put them into series of variables in my new class. And then make a function which will constract the pieces of numbers into one number.

ITS REALLY A CRITICAL WORK. Sorry for my low quality english. And thanks again.

_____________________________________________________________________________

Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->

The problem is that VB only has one unsigned type, which is the Integer. An unsigned long would be nice for this kind of work :-S

But perhaps it is easier in the first place to store your 'number' as a decimal string.

That way, you could take it character by character.

Plus would then be:

Take the first character of both strings.

Convert them to an integer and add them together (in a special function).

Then check if the number is larger than 9. If it is, remember this and substract 10 from it.

The special function should return the single decimal number that came out of the addition (with the 10 dropped from it). If the number was larger than 10, also tell this to the calling function.

Write to the new string this new answer.

Repeat this process for each character. If there was a remainder, don't forget to add this to.

Now I am sorry for my pour explanation. I don't have time right now, but I might clarify this later with an example of what I mean.

Greets...

Richard

Thanks a lot for ur effort of making thinsg yasier. Don't worry, you explained well. I will let u know after completing something that might do the task of the large variable. Another thing is that,

I understand that I have to deal with the overflow to do the addition and for that I have to do recursive calling to a function. After that I can call the addition function for several times to calculate a multiplication or power.

But I don't have any idea of how to do the division task? Should I subtract(-) 155 from 23456 for several times and count a number to find out the integer portion of the result to calculate 23456/155.

Bye for now, Hope to hear form U soon.

_____________________________________________________________________________

Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->

:

: Can anybody give me any idea of a new variable tyep. The question is if I need a variable that would hold more than a double tupe variable then what should I do? Is there any easy way in VB6 which will enable me to create this type of variable and do + - * / works on this type of variable?

:

: I know double is a very very wide one which can hold more than I need, but I wonder what should I do if someone needs one that can hold more than that.

:

: Any Ideas please.

Use Python :-)

I think the Currency type in VB is "bigger" than the Double type.

Seriously, there are algorithms out there for performing arithmetic operations on very large numbers. I don't know how suitable VB is for implementing those algorithms. Python comes with this kind of power out-of-the-box:

[code]

>>> print 10**100

10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[/code]

[size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

[code]

$ select * from users where clue > 0

no rows returned

[/code]

Again I want to say that, this large number value is quite enougn to do everything I need. But what I am trying to find out is How to create a variable larger then the builtin type variables of VB6.

In short if I start with Integer variables it wont be able to hold more than about -32000 to +32000, and about 64000 if it is unsigned (although I have to check it out that whethere VB6 supports unsigned Integer variables). But if I want to make a custom LargeInteger variable that may hold upto +1234567890 to -1234567890 then what should be the most appropriate and effecient way?

Thanks for your response.

_____________________________________________________________________________

Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->

For instance: 34567/155

Substract 155 from 34567 until the remaining number is smaller than 155.

Keep a count of how many times you do this. Call this number n for now.

The remainder will be r.

You'll get an answer: n will be the integer number (dropping the remainder). If you want to round it, check if r > (155 / 2), or in words "If the remainder is larger than half the divisor".

Have fun :-)

(Note that this all is only for Integer numbers. To use decimal numbers, you'll have to think of what to do with the remainder)

Greets...

Richard

: I don't know about Python, Byt VB6 also can support a very very large number. In a Double type variable VB6 can ultimately support more than 300 dizit number value.

:

: Again I want to say that, this large number value is quite enougn to do everything I need. But what I am trying to find out is How to create a variable larger then the builtin type variables of VB6.

:

: In short if I start with Integer variables it wont be able to hold more than about -32000 to +32000, and about 64000 if it is unsigned (although I have to check it out that whethere VB6 supports unsigned Integer variables). But if I want to make a custom LargeInteger variable that may hold upto +1234567890 to -1234567890 then what should be the most appropriate and effecient way?

:

: Thanks for your response.

: _____________________________________________________________________________

: Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->

:

:

Let's see ... Long is 32-bit number (Let's talk integers for now).

Let's also suppose you need a 128-bit number, so ... you'll need four Long numbers:

[code]

FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF

[/code]

As Richard pointed out (was it Richart? I forgot ... sorry) you will need custom made functions for arithmetic operations.

I have a suggestion for division and multiplication.

You suggested that you should subtract 155 times the number 155. So you'll have something like a counter.

subtraction 154

subtraction 153

subtraction 152

... and so on...

subtraction 1

subtraction 0...

Well .. this repeats too many times. How about this:

[code]

We have X/Y. To get the result, we need Y = 1.

So ...

(X/Y) * 1 = X/Y - true

1 = (1/2) / (1/2) - true

=> (X/Y) * [(1/2)/(1/2)] = X/Y

<=> 1 X

- -

X 2 X 2 X

- * - = - OR - = -

Y 1 Y Y Y

- -

2 2

[/code]

The reason to do this is that if you look at the numbers in binary, you'll notice that multiplication and division by is done quite easy:

to multiply by 2 - simply shift the number to the left by 1 bit

to divide by 2 - shift right by 1 bit

You will have to consider carrying bits over to next part of the number.

Example (for simplicity, 16-bit number made up by two 8-bit numbers):

You have the following:

[code]

00000000 10000000

When you multiply by two, you have to shift left by 1 bit, but if you don't consider the carry-over, you will get this:

00000000 00000000

which obviously is not what you want. What you need to do is save the

first bit of the low-order byte, then do the shifting, and then add the carry-over to the high-order byte:

HI LO

initial: 00000000 10000000

save 1st bit: CARRYY_OVER = BIT1(LO) ' = LO & 10000000 (bitwise AND)

shift: 00000000 00000000

add to HI: IF CARRY_OVER <> THEN HI = HI + 1

00000001 00000000

[/code]

VB has built-in operators for shifting: SHL and SHR respectively for shifting left and right. Play around with this. Do some binary aritchemtic on paper using small numbers like two 8-bit numbers just to get a feel of how things work, and to run into some problems, which you will have to solve.

Hope I helped,

Nikolay Semov

I don't understand your calculation, but I do know what you are saying.

I thought about this method too, but it was a bit difficult to explain and besides, I had already suggested using a string rather than 4 longs. The reason for this is because VB does NOT have Unsigned Longs, which means you'll have to take in account the Sign Bit (which is a pain in the ass).

But, you said something about bitshifts (Which would surely make this way easier)? Is that in VB6 or are we talking VB.NET here?

Greets...

Richard

[b][red]This message was edited by Bulgarian_VB at 2005-10-27 9:40:42[/red][/b][hr]

: Thanks for explaining it.

: I don't understand your calculation, but I do know what you are saying.

: I thought about this method too, but it was a bit difficult to explain and besides, I had already suggested using a string rather than 4 longs. The reason for this is because VB does NOT have Unsigned Longs, which means you'll have to take in account the Sign Bit (which is a pain in the ass).

:

: But, you said something about bitshifts (Which would surely make this way easier)? Is that in VB6 or are we talking VB.NET here?

:

: Greets...

: Richard

:

:

VB6 for sure. I don't know about VB.NET.

By the way ... you're looking at bits. Since you are defining operations on those bits, you don't need to care how VB interprets them. So you might as well NOT count a sign bit. Which reminds me: Not only would you have to define operations, but also define printing capabilities, that is... conversion into string. Then, you'll have the freedom to interpret the most significant bit as a sign bit, or not.

By the way .... what if at some point you need to use that large large number in a SQRT or trig function. Then you'll have a lot of trouble. Not that it's imposible, but there's a lot of work. When I think of it, actually, trig functions won't be that difficult since they are periodic, but anyway...

Hope I helped,

Nikolay Semov

Thanks everybody for ur responses. Those ideas are really helpful.

I learned about the bitwise division and multiplication in Assembly and C. But did not know whethere it would be applicable in VB6. Thanks fellows for the ideas.

Hear is something more interesting. Instead of making just a fixed length variable type, We can also build a function that takes the number of byte the new variable might take and then adjust all the related functions about + - * / accoudingly.

I think I m talking about a special type of ofject.

Thanks to everybody again.

_____________________________________________________________________________

Knowledge Is Power. Be Sure To Use This Power For Others WelFare. (;->

If there really is a bitshift in Vb6, then the sign bit is no longer any problem (not that it ever was, but without a bitshift you'll have to account for the sign bit, because you are modifying the number using numbers, not binary operations).

Greets...

Richard