Search This Blog

pCloud Crypto

The DEC2HEX function with examples in Excel

The DEC2HEX function in Microsoft Excel converts a decimal number to its hexadecimal equivalent. Here’s how it works:

  • SyntaxDEC2HEX(number, [places])

    • number: The decimal integer you want to convert. If the number is negative, the places argument is ignored, and DEC2HEX returns a 10-character (40-bit) hexadecimal number. The most significant bit represents the sign, and the remaining 39 bits represent magnitude (using two’s-complement notation for negative numbers).
    • places (optional): The number of characters to use. If omitted, DEC2HEX uses the minimum necessary characters. It’s useful for padding the return value with leading zeros.
  • If number is less than -549,755,813,888 or greater than 549,755,813,887, DEC2HEX returns the #NUM! error value.

  • If number is non-numeric, DEC2HEX returns the #VALUE! error value.

  • If the result of DEC2HEX requires more characters than specified by places, it returns the #NUM! error value. For example, DEC2HEX(64,1) returns an error because the result (40) requires two characters.

  • If places is not an integer, its value is truncated. If places is negative, DEC2HEX returns the #NUM! error value.

Here are some examples:

  1. To convert decimal 100 to hexadecimal with 4 characters (padded with two leading zeros): =DEC2HEX(100, 4) ➡️ Result: 0064
  2. To convert decimal -54: =DEC2HEX(-54) ➡️ Result: FFFFFFFCA
  3. To convert decimal 28: =DEC2HEX(28) ➡️ Result: 1C
  4. Attempting to convert decimal 64 with only 1 character place: =DEC2HEX(64,1) ➡️ Result: #NUM!

Feel free to try it out in your Excel worksheet!

No comments:

Post a Comment

pCloud Lifetime

The customer care and complaint management contact details for BASIC Bank Limited

If you need to get in touch with  BASIC Bank Limited  in Bangladesh regarding complaints or suggestions, here are the ways you can reach the...