Thursday, October 2, 2008

VBScript Adding Large Hex Strings

This function is an example of how to add two large hex strings together keeping them as string values:
Function HexAdd(ByVal strNum1, ByVal strNum2)
size1 = Len(strNum1)
size2 = Len(strNum2)
If (size1 <> size2) Then
If (size1 > size2) Then
strNum2 = String(size1 - size2, "0") + strNum2
size2 = size1
Else
strNum1 = String(size2 - size1, "0") + strNum1
size1 = size2
End If
End If
' Begin adding
Dim i
Dim ret
Dim carry
Dim sum
ret = ""
i = CDbl(0)
carry = 0
For i = 1 To size1 '199999999999999999999998
a = "&H" & CStr(Mid(strNum1, size1 - i + 1, 1))
b = "&H" & CStr(Mid(strNum2, size1 - i + 1, 1))
sum = CInt(a) + CInt(b) + carry
ret = Hex(CStr(sum Mod 16)) & ret
carry = Fix(sum / 16)
Next
If (carry > 0) Then
ret = CStr(Hex(carry)) & ret
End If
HexAdd = ret
End Function

Call it like this:

ret = HexAdd("FFFFF", "123456789ABCDEF")

Wednesday, October 1, 2008

Handling Large Hex in VBScript

VBScript doesn't inherently support hex constants over 8 bits in length so I made a little function that attempts to handle large Hex strings and convert them to Decimals. It should be noted that Doubles lose precision in the E15 range of magnitude so beware using anything too large:
Function HexToDec(strHex)
Dim i
Dim size
Dim ret
size = Len(strHex) - 1
ret = CDbl(0)
For i = 0 To size
ret = ret + CDbl("&H" & Mid(strHex, size - i + 1, 1)) * (CDbl(16) ^ CDbl(i))
Next
HexToDec = ret
End Function
Function DecToHex(dblNumber)
Dim Q
Dim ret

ret = ""
Q = CDbl(Fix(dblNumber))
While Q > 0
ret = Hex(Q - Fix(Q / 16) * 16) & ret
Q = Fix(Q / CDbl(16))
Wend
DecToHex = ret
End Function

Called like this:

ret = HexToDec("0C0BA715B2223D47A8CAC87BE5D9679")
ret = DecToHex(CDBL(16843216856846468461654862))

Big Progressive is Watching

I’ve thought about this kind of device on more than one occasion, but it seems like it would raise privacy concerns. The device hooks into your OBD2 and transmits data to Progressive about how much you drive, how fast you turn, start, or stop, and what time of day you are driving.

They assure the consumer that unless legally obligated they will keep the information about your driving style to themselves, but I'm guessing it won't be long before the culpable driver in accidents will be determined with a device such as these. Beware consumer - Big Progressive is watching!


http://progressive.com/myrate/

Wednesday, September 24, 2008

Male Chauvinist Pigs Make More Money?

That's what this article says on the livescience website:

Men With Traditional Views on Sex Roles Earn More Money

Isn't that interesting? The comments at the bottom gave some interesting ideas as to why there may be a correlation.

I would question whether it's just a simple issue of age of theology, because older individuals tend to have more traditional beliefs and they tend to be further along in their career hence making more money. I wonder what the trend will look like in about 50-60 years.

Star Wars: The Force Unleashed - Manual poorly printed for Wii

For those of you reading this post in the hopes of finding a walkthrough please check this one out (starts on page 4):

IGN Guide

First let me say, I like to play Force Unleashed on the Wii. I think that despite it's shortcomings as a game the story is entertaining and I like the force powers enough to enjoy it and recommend it.

One thing that is driving me absolutely crazy is the lousy printing job done on the manual. I'll scan some pages in and add them to this post later.

UPDATE: Here they are:









Honestly though, it's all black and white. I can't see half the pictures as anything besides black squares and the descriptions on how to work things is so limited it's a real let down. I guess all the time they should have been pouring into the manual ended up as the tutorial section of the game and all the helpful tips.

Please next time let's use the color printer - Lucas Arts are you listening?