Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Converting Hexadecimal/octal to decimal


zekewalton

Recommended Posts

I need to convert hexadecimal numbers to decimal numbers across the range of 0000 - FFFF

and octal numbers to decimal for the range of 000-888. Are there any converters readily available?

 

Thanks

Zeke

Link to comment
Share on other sites

Hmmmmmmm. Shouldn't your octal range be 000-777 ?

 

There must be a more "elegant" way than this - but until someone posts it, these will work.

 

Anyhow, here are 3 long calculations which will deliver binary, octal and hex conversions to decimal up to the limit of Filemaker's accuracy (15 digits). Binary = 48 characters, Octal = 16 characters, hex = 12 characters. In each case, the respective input field is a text field.

 

Binary:

 

Right(Binary Input,1) +

Case(Length(Binary Input)>1,Middle(Binary Input,Length(Binary Input)-1,1) * 2^1,0) +

Case(Length(Binary Input)>2,Middle(Binary Input,Length(Binary Input)-2,1) * 2^2,0) +

Case(Length(Binary Input)>3,Middle(Binary Input,Length(Binary Input)-3,1) * 2^3,0) +

Case(Length(Binary Input)>4,Middle(Binary Input,Length(Binary Input)-4,1) * 2^4,0) +

Case(Length(Binary Input)>5,Middle(Binary Input,Length(Binary Input)-5,1) * 2^5,0) +

Case(Length(Binary Input)>6,Middle(Binary Input,Length(Binary Input)-6,1) * 2^6,0) +

Case(Length(Binary Input)>7,Middle(Binary Input,Length(Binary Input)-7,1) * 2^7,0) +

Case(Length(Binary Input)>8,Middle(Binary Input,Length(Binary Input)-8,1) * 2^8,0) +

Case(Length(Binary Input)>9,Middle(Binary Input,Length(Binary Input)-9,1) * 2^9,0) +

Case(Length(Binary Input)>10,Middle(Binary Input,Length(Binary Input)-10,1) * 2^10,0) +

Case(Length(Binary Input)>11,Middle(Binary Input,Length(Binary Input)-11,1) * 2^11,0) +

Case(Length(Binary Input)>12,Middle(Binary Input,Length(Binary Input)-12,1) * 2^12,0) +

Case(Length(Binary Input)>13,Middle(Binary Input,Length(Binary Input)-13,1) * 2^13,0) +

Case(Length(Binary Input)>14,Middle(Binary Input,Length(Binary Input)-14,1) * 2^14,0) +

Case(Length(Binary Input)>15,Middle(Binary Input,Length(Binary Input)-15,1) * 2^15,0) +

Case(Length(Binary Input)>16,Middle(Binary Input,Length(Binary Input)-16,1) * 2^16,0) +

Case(Length(Binary Input)>17,Middle(Binary Input,Length(Binary Input)-17,1) * 2^17,0) +

Case(Length(Binary Input)>18,Middle(Binary Input,Length(Binary Input)-18,1) * 2^18,0) +

Case(Length(Binary Input)>19,Middle(Binary Input,Length(Binary Input)-19,1) * 2^19,0) +

Case(Length(Binary Input)>20,Middle(Binary Input,Length(Binary Input)-20,1) * 2^20,0) +

Case(Length(Binary Input)>21,Middle(Binary Input,Length(Binary Input)-21,1) * 2^21,0) +

Case(Length(Binary Input)>22,Middle(Binary Input,Length(Binary Input)-22,1) * 2^22,0) +

Case(Length(Binary Input)>23,Middle(Binary Input,Length(Binary Input)-23,1) * 2^23,0) +

Case(Length(Binary Input)>24,Middle(Binary Input,Length(Binary Input)-24,1) * 2^24,0) +

Case(Length(Binary Input)>25,Middle(Binary Input,Length(Binary Input)-25,1) * 2^25,0) +

Case(Length(Binary Input)>26,Middle(Binary Input,Length(Binary Input)-26,1) * 2^26,0) +

Case(Length(Binary Input)>27,Middle(Binary Input,Length(Binary Input)-27,1) * 2^27,0) +

Case(Length(Binary Input)>28,Middle(Binary Input,Length(Binary Input)-28,1) * 2^28,0) +

Case(Length(Binary Input)>29,Middle(Binary Input,Length(Binary Input)-29,1) * 2^29,0) +

Case(Length(Binary Input)>30,Middle(Binary Input,Length(Binary Input)-30,1) * 2^30,0) +

Case(Length(Binary Input)>31,Middle(Binary Input,Length(Binary Input)-31,1) * 2^31,0) +

Case(Length(Binary Input)>32,Middle(Binary Input,Length(Binary Input)-32,1) * 2^32,0) +

Case(Length(Binary Input)>33,Middle(Binary Input,Length(Binary Input)-33,1) * 2^33,0) +

Case(Length(Binary Input)>34,Middle(Binary Input,Length(Binary Input)-34,1) * 2^34,0) +

Case(Length(Binary Input)>35,Middle(Binary Input,Length(Binary Input)-35,1) * 2^35,0) +

Case(Length(Binary Input)>36,Middle(Binary Input,Length(Binary Input)-36,1) * 2^36,0) +

Case(Length(Binary Input)>37,Middle(Binary Input,Length(Binary Input)-37,1) * 2^37,0) +

Case(Length(Binary Input)>38,Middle(Binary Input,Length(Binary Input)-38,1) * 2^38,0) +

Case(Length(Binary Input)>39,Middle(Binary Input,Length(Binary Input)-39,1) * 2^39,0) +

Case(Length(Binary Input)>40,Middle(Binary Input,Length(Binary Input)-40,1) * 2^40,0) +

Case(Length(Binary Input)>41,Middle(Binary Input,Length(Binary Input)-41,1) * 2^41,0) +

Case(Length(Binary Input)>42,Middle(Binary Input,Length(Binary Input)-42,1) * 2^42,0) +

Case(Length(Binary Input)>43,Middle(Binary Input,Length(Binary Input)-43,1) * 2^43,0) +

Case(Length(Binary Input)>44,Middle(Binary Input,Length(Binary Input)-44,1) * 2^44,0) +

Case(Length(Binary Input)>45,Middle(Binary Input,Length(Binary Input)-45,1) * 2^45,0) +

Case(Length(Binary Input)>46,Middle(Binary Input,Length(Binary Input)-46,1) * 2^46,0) +

Case(Length(Binary Input)>47,Middle(Binary Input,Length(Binary Input)-47,1) * 2^47,0)

 

Octal:

 

Right(Octal Input,1) +

Case(Length(Octal Input)>1,Middle(Octal Input,Length(Octal Input)-1,1) * 8^1,0) +

Case(Length(Octal Input)>2,Middle(Octal Input,Length(Octal Input)-2,1) * 8^2,0) +

Case(Length(Octal Input)>3,Middle(Octal Input,Length(Octal Input)-3,1) * 8^3,0) +

Case(Length(Octal Input)>4,Middle(Octal Input,Length(Octal Input)-4,1) * 8^4,0) +

Case(Length(Octal Input)>5,Middle(Octal Input,Length(Octal Input)-5,1) * 8^5,0) +

Case(Length(Octal Input)>6,Middle(Octal Input,Length(Octal Input)-6,1) * 8^6,0) +

Case(Length(Octal Input)>7,Middle(Octal Input,Length(Octal Input)-7,1) * 8^7,0) +

Case(Length(Octal Input)>8,Middle(Octal Input,Length(Octal Input)-8,1) * 8^8,0) +

Case(Length(Octal Input)>9,Middle(Octal Input,Length(Octal Input)-9,1) * 8^9,0) +

Case(Length(Octal Input)>10,Middle(Octal Input,Length(Octal Input)-10,1) * 8^10,0) +

Case(Length(Octal Input)>11,Middle(Octal Input,Length(Octal Input)-11,1) * 8^11,0) +

Case(Length(Octal Input)>12,Middle(Octal Input,Length(Octal Input)-12,1) * 8^12,0) +

Case(Length(Octal Input)>13,Middle(Octal Input,Length(Octal Input)-13,1) * 8^13,0) +

Case(Length(Octal Input)>14,Middle(Octal Input,Length(Octal Input)-14,1) * 8^14,0) +

Case(Length(Octal Input)>15,Middle(Octal Input,Length(Octal Input)-15,1) * 8^15,0) +

Case(Length(Octal Input)>16,Middle(Octal Input,Length(Octal Input)-16,1) * 8^16,0)

 

Hex:

 

Case(

IsEmpty(Hexadecimal Input),0,

Position("0123456789ABCDEF",Right(Hexadecimal Input,1), 1, 1) -1 +

Case(Length(Hexadecimal Input)>1,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-1,1), 1, 1) -1) * 16^1,0) +

Case(Length(Hexadecimal Input)>2,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-2,1), 1, 1) -1) * 16^2,0) +

Case(Length(Hexadecimal Input)>3,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-3,1), 1, 1) -1) * 16^3,0) +

Case(Length(Hexadecimal Input)>4,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-4,1), 1, 1) -1) * 16^4,0) +

Case(Length(Hexadecimal Input)>5,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-5,1), 1, 1) -1) * 16^5,0) +

Case(Length(Hexadecimal Input)>6,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-6,1), 1, 1) -1) * 16^6,0) +

Case(Length(Hexadecimal Input)>7,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-7,1), 1, 1) -1) * 16^7,0) +

Case(Length(Hexadecimal Input)>8,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-8,1), 1, 1) -1) * 16^8,0) +

Case(Length(Hexadecimal Input)>9,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-9,1), 1, 1) -1) * 16^9,0) +

Case(Length(Hexadecimal Input)>10,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-10,1), 1, 1) -1) * 16^10,0) +

Case(Length(Hexadecimal Input)>11,(Position("0123456789ABCDEF",Middle(Hexadecimal Input,Length(Hexadecimal Input)-11,1), 1, 1) -1) * 16^11,0)

)

Link to comment
Share on other sites

Look at This file , that I've posted some time ago.

for hex coversion set "chars to use" to 0123456789ABCDEF

and for octal

01234567

also set trailing digits to 0

 

Dj

 

PS octals don't have digit 8

 

Originally posted by zekewalton:

[qb]I need to convert hexadecimal numbers to decimal numbers across the range of 0000 - FFFF

and octal numbers to decimal for the range of 000-888. Are there any converters readily available?

 

Thanks

Zeke[/qb]

Link to comment
Share on other sites



×
×
  • Create New...

Important Information

Terms of Use