1 Attachment(s)
Anyone want to try and break this?
About a week ago, I tried to find a good VB class for handling large numbers. The only thing I could find was a .dll written in C, so I thought I'd try to cook up one written in VB to get a little coding practice. Attached is what I came up with. It handles signed, floating point numbers up to roughly the length of the max value of an Integer. It can perform all simple math functions (add, subtract, multiply, divide, integer divide, modulus), raise numbers to positive and negative integer powers, and can evaluate greater than and less than. For good measure, I also put in functions to convert to and from any base from 2 to 35, a reciprocal function, a crude formatter, and 6 bitwise operations.
Everything works as far as I can tell, but I was wondering if anyone could test it a little bit before I put it in the code bank.
Re: Anyone want to try and break this?
Seems nice! I still don't create an instance of this class, I've been looking around properties and methods. I saw you used "." many times to find decimal places,
In some countries like mine, people use "," as decimal symbol.
If you want you could get it like this:
VB Code:
Private mDecSymbol as String
mDecSymbol = Format$(0, ".")
This way mDecSymbol will be the decimal symbol used in that computer, like it is in Regional Settings.
Then you could replace all your "." by mDecSymbol.
(Just an idea) :wave:
Re: Anyone want to try and break this?
Re: Anyone want to try and break this?
Quote:
Originally Posted by jcis
Seems nice! I still don't create an instance of this class, I've been looking around properties and methods. I saw you used "." many times to find decimal places,
In some countries like mine, people use "," as decimal symbol.
If you want you could get it like this:
Thanks, this is just the type of thing I was looking for. I'll update it later tonight and re-attach the fixed version. If you want to play around with it before then, a work-around would be to pass all of the arguments explicitly as strings.
Re: Anyone want to try and break this?
OK, I added the decimal point fix and also added code to get a regionally correct thousands separator. Finally, I fixed some typos in the docs and made .Number the default property.