pvivacqua Posted May 6, 2003 Posted May 6, 2003 Does anybody have a script for converting a hexadecimal number into a decimal number. thanks
Ugo DI LUCA Posted May 6, 2003 Posted May 6, 2003 Hi, sorry for my ignorance but is hexadecimal 12,22654587 and you want it to be 12,25 ? If so, try a calculation instead of a script : Int((your number field + .12) * 4) / 4
cjaeger Posted May 6, 2003 Posted May 6, 2003 (Position("0123456789ABCDEF";Middle(Hex;1;1);1;1)-1) *16 + (Position("0123456789ABCDEF";Middle(Hex;2;1);1;1)-1) for 2-digit hex numbers. for 3 digit: (Position("0123456789ABCDEF";Middle(Hex;1;1);1;1)-1) *16*16 +(Position("0123456789ABCDEF";Middle(Hex;1;1);1;1)-1) *16 + (Position("0123456789ABCDEF";Middle(Hex;2;1);1;1)-1) and so on Good Mornung UGO, still at work? [substitute the ";" for "," in the US)
RussBaker Posted May 6, 2003 Posted May 6, 2003 I'm still working on my next version of the RussCalcs from Oz file (normally found under the samples section of this forum). So there still are some spare sections in this attachment - but the binary / octal / hex and generic Base (Base34 in the example) calculations are all done. In the attached file, click on the BASE tab and you can see these calcs. RussCalcs from Oz v5.fp5.zip
RussBaker Posted May 6, 2003 Posted May 6, 2003 But if all you're after is the Hex to decimal calculation itself, here it is: This works from the Hex Input being in the Base_Hex_IP field (text). Maximum length of the Hex string this will handle is 12 (FFFFFFFFFFFF). Case( IsEmpty(Base_Hex_IP),0, Position("0123456789ABCDEF",Right(Base_Hex_IP,1), 1, 1) -1 + Case(Length(Base_Hex_IP)>1,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-1,1), 1, 1) -1) * 16^1,0) + Case(Length(Base_Hex_IP)>2,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-2,1), 1, 1) -1) * 16^2,0) + Case(Length(Base_Hex_IP)>3,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-3,1), 1, 1) -1) * 16^3,0) + Case(Length(Base_Hex_IP)>4,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-4,1), 1, 1) -1) * 16^4,0) + Case(Length(Base_Hex_IP)>5,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-5,1), 1, 1) -1) * 16^5,0) + Case(Length(Base_Hex_IP)>6,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-6,1), 1, 1) -1) * 16^6,0) + Case(Length(Base_Hex_IP)>7,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-7,1), 1, 1) -1) * 16^7,0) + Case(Length(Base_Hex_IP)>8,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-8,1), 1, 1) -1) * 16^8,0) + Case(Length(Base_Hex_IP)>9,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-9,1), 1, 1) -1) * 16^9,0) + Case(Length(Base_Hex_IP)>10,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-10,1), 1, 1) -1) * 16^10,0) + Case(Length(Base_Hex_IP)>11,(Position("0123456789ABCDEF",Middle(Base_Hex_IP,Length(Base_Hex_IP)-11,1), 1, 1) -1) * 16^11,0) )
Recommended Posts
This topic is 7942 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now