am tring to conver the left number in the atached image to the on on the right but i recive overflow
http://bb.1asphost.com/pelegk2/333.GIf
how can i slove this problem?
thnaks i nadvance
peleg
Printable View
am tring to conver the left number in the atached image to the on on the right but i recive overflow
http://bb.1asphost.com/pelegk2/333.GIf
how can i slove this problem?
thnaks i nadvance
peleg
Unfortunately, that large of a number is too much for even a Long.
Singles and Doubles can hold it, but because they use significant digits, the value of the number gets changed.
With Single:
Entered 144614369260322395
Returned 144614366354866176
With Double:
Entered 144614369260322395
Returned 144614369260322400
My best suggestion would be to convert the hex into a String, and whenever you make comparisons, if you make any, just make sure the value it's being compared against gets put into CStr().
Strings can perform direct comparisons with number strings perfectly as far as I can see, so "500" < "600" will return True, "455" <= "300" will return False, "400" <> "400" will return False, etc.
i didnt execlly understamdnd you
i ned oo convert 1 of them to the other format before i can compre!
how will i do it?
Make the comparisons as strings.
Meaning, make both values being compared into Strings when you compare them, using the CStr() function if necessary.
Hi !
I'm working on that. Hope to present you a solution soon. 100 decimal digits are enough ?
Jonny Poet
Here are some converterfunctions I have done for u, working up to 100 decimal digits
Please test them. Hope that helps
Jonny Poet
Yea, but I think he has to compare long decimals against hex values !! so he has to convert one of them before he can compare.Quote:
Originally Posted by ChaosTheEternal
So I did some converters.
:wave: Jonny Poet
Hey Jonny you are great... Thanks for help.Quote:
Originally Posted by JonnyPoet
P.S : I love this site.... I think the best coding site on the planet
hey Joney it worked!
i need only 15 number length:)
thnaks alot great day and great weekd end
peleg
maybe u have the opposite:
from dec to hex?
VB already has that built in:
Hex(Number)
It returns the number as a hexadecimal String.
... unfortunately, Hex can't handle values larger than Longs.
You would have to do some manual conversion.
Yes I tried that, but putting in, the given number 144614369260322395 is changed to an format with exponent ( I dont know english expression ) 1446...E+17 something like that so its not really usable I think.Quote:
Originally Posted by ChaosTheEternal
I'll do that from a string-number like "1446..." into a hex string in the evening ( Its just now 3 PM in Vienna) so in some hours it should be done
Jonny Poet
Just one note here ... the above examples work because they the same length.. if you try "9" < "10" you get false.. because in text digit 1 is compared to Digit 1 then digit 2, 3.....Quote:
Originally Posted by ChaosTheEternal
In this case use format to add in leading 0's
Gremmy
Yes Gremmy you talked out of my soul. Yesterday I want to mention that, then I forgot. Today it was on my list to do that. You did :thumb:Quote:
Originally Posted by GremlinSA
BTW I just started to program the Long-Decimal-string to Binary and to Hex functions. Will be ready soon I hope.
For comparing strings, you could opt to check the lengths of them first, then the strings.
Code:If Len(strOne) = Len(strTwo) Then
If strOne > strTwo Then MsgBox "strOne is larger"
If strOne < strTwo Then MsgBox "strTwo is larger"
If strOne = strTwo Then MsgBox "strOne = strTwo"
Else
If Len(strOne) > Len(strTwo) Then MsgBox "strOne is larger"
If Len(strOne) < Len(strTwo) Then MsgBox "strTwo is larger"
End If