Excel number to hex

Excel для Microsoft 365 Excel для Microsoft 365 для Mac Excel для Интернета Excel 2021 Excel 2021 для Mac Excel 2019 Excel 2019 для Mac Excel 2016 Excel 2016 для Mac Excel 2013 Excel 2010 Excel 2007 Excel для Mac 2011 Excel Starter 2010 Еще…Меньше

В этой статье описаны синтаксис формулы и использование функции ДЕС.В.ШЕСТН в Microsoft Excel.

Описание

Преобразует десятичное число в шестнадцатеричное.

Синтаксис

ДЕС.В.ШЕСТН(число;[разрядность])

Аргументы функции ДЕС.В.ШЕСТН описаны ниже.

  • Число    — обязательный аргумент. Преобразуемое десятичное число. Если оно отрицательное, то разрядность игнорируется и функция ДЕС.В.ШЕСТН возвращает 10-значное (40-битное) шестнадцатеричное число, в котором самый старший бит является знаковым битом. Остальные 39 бит являются битами значения. Отрицательные числа представляются в дополнительных кодах.

  • Разрядность    Необязательный. Количество знаков в записи числа. Если разрядность опущена, функция ДЕС.В.ШЕСТН использует минимально необходимое количество знаков. Разрядность используется, чтобы приписать возвращаемому значению ведущие нули.

Замечания

  • Если число < -549 755 813 888 или число > 549 755 813 887, то DEC2HEX возвращает #NUM! значение ошибки #ЗНАЧ!.

  • Если число не является числом, то DEC2HEX возвращает #VALUE! значение ошибки #ЗНАЧ!.

  • Если для результата DEC2HEX требуется больше количества знаков Знаков знаков Знаков после заданного числа знаков Знаков после заданного числа знаков, возвращается #NUM! значение ошибки #ЗНАЧ!.
    Например, DEC2HEX(64;1) возвращает значение ошибки, так как для результата (40) требуется два знака.

  • Если значение аргумента «разрядность» не является целым числом, оно усекается.

  • Если число не является числом, то DEC2HEX возвращает #VALUE! значение ошибки #ЗНАЧ!.

  • Если «количество» отрицательное, то DEC2HEX возвращает #NUM! значение ошибки #ЗНАЧ!.

Пример

Скопируйте образец данных из следующей таблицы и вставьте их в ячейку A1 нового листа Excel. Чтобы отобразить результаты формул, выделите их и нажмите клавишу F2, а затем — клавишу ВВОД. При необходимости измените ширину столбцов, чтобы видеть все данные.

Формула

Описание

Результат

=ДЕС.В.ШЕСТН(100;4)

Преобразует десятичное число 100 в шестнадцатеричное из 4 знаков (с «приписанными» двумя ведущими нулями).

0064

=ДЕС.В.ШЕСТН(-54)

Преобразует десятичное значение -54 в шестнадцатеричное

FFFFFFFFCA

=ДЕС.В.ШЕСТН(28)

Преобразует десятичное значение 28 в шестнадцатеричное.

1C

=ДЕС.В.ШЕСТН(64;1)

Возвращает #NUM! из-за того, что для результата (40) требуется 2 знака.

#ЧИСЛО!

Нужна дополнительная помощь?

Содержание

  1. Функция ДЕС.В.ШЕСТН
  2. Описание
  3. Синтаксис
  4. Замечания
  5. Пример
  6. BIN2HEX function
  7. Description
  8. Syntax
  9. Remarks
  10. Example
  11. DEC2HEX function
  12. Description
  13. Syntax
  14. Remarks
  15. Example
  16. Функция ДВ.В.ШЕСТН
  17. Описание
  18. Синтаксис
  19. Замечания
  20. Пример
  21. Working with HEX values in Excel
  22. What is Hexadecimal?
  23. Converting Hexadecimal values to Decimal in Excel
  24. Dealing with 0x prefixes
  25. A working example

Функция ДЕС.В.ШЕСТН

В этой статье описаны синтаксис формулы и использование функции ДЕС.В.ШЕСТН в Microsoft Excel.

Описание

Преобразует десятичное число в шестнадцатеричное.

Синтаксис

Аргументы функции ДЕС.В.ШЕСТН описаны ниже.

Число — обязательный аргумент. Преобразуемое десятичное число. Если оно отрицательное, то разрядность игнорируется и функция ДЕС.В.ШЕСТН возвращает 10-значное (40-битное) шестнадцатеричное число, в котором самый старший бит является знаковым битом. Остальные 39 бит являются битами значения. Отрицательные числа представляются в дополнительных кодах.

Разрядность Необязательный. Количество знаков в записи числа. Если разрядность опущена, функция ДЕС.В.ШЕСТН использует минимально необходимое количество знаков. Разрядность используется, чтобы приписать возвращаемому значению ведущие нули.

Замечания

Если число 549 755 813 887, то DEC2HEX возвращает #NUM! значение ошибки #ЗНАЧ!.

Если число не является числом, то DEC2HEX возвращает #VALUE! значение ошибки #ЗНАЧ!.

Если для результата DEC2HEX требуется больше количества знаков Знаков знаков Знаков после заданного числа знаков Знаков после заданного числа знаков, возвращается #NUM! значение ошибки #ЗНАЧ!.
Например, DEC2HEX(64;1) возвращает значение ошибки, так как для результата (40) требуется два знака.

Если значение аргумента «разрядность» не является целым числом, оно усекается.

Если число не является числом, то DEC2HEX возвращает #VALUE! значение ошибки #ЗНАЧ!.

Если «количество» отрицательное, то DEC2HEX возвращает #NUM! значение ошибки #ЗНАЧ!.

Пример

Скопируйте образец данных из следующей таблицы и вставьте их в ячейку A1 нового листа Excel. Чтобы отобразить результаты формул, выделите их и нажмите клавишу F2, а затем — клавишу ВВОД. При необходимости измените ширину столбцов, чтобы видеть все данные.

Преобразует десятичное число 100 в шестнадцатеричное из 4 знаков (с «приписанными» двумя ведущими нулями).

Преобразует десятичное значение -54 в шестнадцатеричное

Преобразует десятичное значение 28 в шестнадцатеричное.

Возвращает #NUM! из-за того, что для результата (40) требуется 2 знака.

Источник

BIN2HEX function

This article describes the formula syntax and usage of the BIN2HEX function in Microsoft Excel.

Description

Converts a binary number to hexadecimal.

Syntax

The BIN2HEX function syntax has the following arguments:

Number Required. The binary number you want to convert. Number cannot contain more than 10 characters (10 bits). The most significant bit of number is the sign bit. The remaining 9 bits are magnitude bits. Negative numbers are represented using two’s-complement notation.

Places Optional. The number of characters to use. If places is omitted, BIN2HEX uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

If number is not a valid binary number, or if number contains more than 10 characters (10 bits), BIN2HEX returns the #NUM! error value.

If number is negative, BIN2HEX ignores places and returns a 10-character hexadecimal number.

If BIN2HEX requires more than places characters, it returns the #NUM! error value.

If places is not an integer, it is truncated.

If places is nonnumeric, BIN2HEX returns the #VALUE! error value.

If places is negative, BIN2HEX returns the #NUM! error value.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Converts binary 11111011 to hexadecimal with 4 characters

Источник

DEC2HEX function

This article describes the formula syntax and usage of the DEC2HEX function in Microsoft Excel.

Description

Converts a decimal number to hexadecimal.

Syntax

The DEC2HEX function syntax has the following arguments:

Number Required. The decimal integer you want to convert. If number is negative, places is ignored and DEC2HEX returns a 10-character (40-bit) hexadecimal number in which the most significant bit is the sign bit. The remaining 39 bits are magnitude bits. Negative numbers are represented using two’s-complement notation.

Places Optional. The number of characters to use. If places is omitted, DEC2HEX uses the minimum number of characters necessary. Places is useful for padding the return value with leading 0s (zeros).

If Number is 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 than the number of specified Places characters, it returns the #NUM! error value.
For example, DEC2HEX(64,1) returns the error value because the result (40) requires two characters.

If Places is not an integer, the value of Places is truncated.

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

If Places is negative, DEC2HEX returns the #NUM! error value.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Converts decimal value 100 to hexadecimal with 4 characters («padded» with two leading zeros).

Converts decimal value -54 to hexadecimal

Converts decimal value 28 to hexadecimal.

Returns the #NUM! error value because the result (40) requires 2 character places.

Источник

Функция ДВ.В.ШЕСТН

В этой статье описаны синтаксис формулы и использование функции ДВ.В.ШЕСТН в Microsoft Excel.

Описание

Преобразует двоичное число в шестнадцатеричное.

Синтаксис

Аргументы функции ДВ.В.ШЕСТН описаны ниже.

Число — обязательный аргумент. Преобразуемое двоичное число. Число не должно содержать более 10 знаков (10 бит). Первый значащий бит числа является знаковым битом. Остальные 9 бит являются битами значения. Отрицательные числа представляются в дополнительных кодах.

Разрядность Необязательный. Количество знаков в записи числа. Если разрядность не указана, функция ДВ.В.ШЕСТН использует минимальное необходимое количество знаков. Разрядность используется для дополнения возвращаемого значения ведущими нулями.

Замечания

Если число не является допустимым двоичным числом или содержит более 10 знаков (10 бит), bin2HEX возвращает #NUM! значение ошибки #ЗНАЧ!.

Если число отрицательное, функция ДВ.В.ШЕСТН игнорирует разрядность и возвращает 10-разрядное шестнадцатеричное число.

Если для работы СДВ.В.ВЕХ требуется больше знаков, чем места, возвращается #NUM! значение ошибки #ЧИСЛО!.

Если значение аргумента «разрядность» не является целым числом, оно усекается.

Если число не является числом, то bin2HEX возвращает #VALUE! значение ошибки #ЗНАЧ!.

Если количество мест отрицательное, то bin2HEX возвращает #NUM! значение ошибки #ЗНАЧ!.

Пример

Скопируйте образец данных из следующей таблицы и вставьте их в ячейку A1 нового листа Excel. Чтобы отобразить результаты формул, выделите их и нажмите клавишу F2, а затем — клавишу ВВОД. При необходимости измените ширину столбцов, чтобы видеть все данные.

Преобразует двоичное число 11111011 в шестнадцатеричное с разрядностью 4

Преобразует двоичное число 1110 в шестнадцатеричное

Преобразует двоичное число 1111111111 в шестнадцатеричное

Источник

Working with HEX values in Excel

It’s unusual to need to work with Hexadecimal values in Excel, but on these rare occasions it can be challenging to figure out how Excel deals with values of this kind. If you simply enter a value like 0xABCDEF78 Excel will treat it as text and won’t recognize it as a numeric value.

What is Hexadecimal?

Hexadecimal (or Hex for short) is a counting system that uses 16 symbols as opposed to the 10 symbols used in the Decimal counting system that we use more often. Hexadecimal uses the letters A-F as well as the numbers 0-9.

Hexadecimal is most often used by computer systems, though it is also used in some advanced mathematical calculations outside of the world of computing.

Converting Hexadecimal values to Decimal in Excel

Excel won’t recognize a Hexadecimal value, but there is a function in its function library that will convert Hexadecimal values into Decimals: the HEX2DEC function.

For example: =HEX2DEC(“FF”) will return 255 – the decimal conversion of the Hexadecimal value FF.

If you’re unfamiliar with Excel functions and formulas you might benefit from our completely free Basic Skills E-book, which will introduce you to the basics of formulas and functions.

Dealing with 0x prefixes

Many programming languages prefix Hexadecimal values with 0x. For example 0xFF instead of just FF.

The HEX2DEC function won’t recognize a Hex value that has a 0x prefix so you will need to strip away the prefixes before you can convert the values.

There are a few different ways you could do this, including Flash Fill, Text To Columns and even Find & Replace, but a formula offers the most long-term solution because it will automatically recalculate. This formula will remove the 0x prefixes:

=RIGHT(A2,LEN(A2)-2)

All of the options mentioned above (as well as the RIGHT and LEN functions) are explained in depth in our Expert Skills Books and E-books.

A working example

You can download an example workbook showing the above functions and formulas in action.

Источник

Преобразование десятичного числа (decimal) в его шестнадцатеричное представление (hexadecimal) с помощью функции Hex в VBA Excel. Примеры.

Hex – это функция, которая возвращает шестнадцатеричное представление заданного десятичного числа. Тип возвращаемого значения – String.

Синтаксис

Number – строковое или числовое выражение, возвращающее число в диапазоне от -2 147 483 648 до 2 147 483 647 (соответствует типу данных Long).

Примечания

  • Функция Hex возвращает шестнадцатеричные значения до 8 знаков.
  • Дробные значения параметра Number округляются до целых.
  • Обратное преобразование шестнадцатеричных чисел в десятичные осуществляется с помощью префикса &H.

Примеры

Пример 1
Варианты преобразования десятичных чисел, возвращенных числовыми и строчными выражениями:

Sub Primer()

    Cells(1, 1) = Hex(4568799 + 45687 * 2) ‘Результат: 471BCD

    Cells(2, 1) = Hex(«35124» & «4581») ‘Результат: 14EF9125

    Cells(3, 1) = Hex(CDate(«21.04.2021»)) ‘Результат: AD13

End Sub

Пример 2
Пользовательская функция, преобразующая десятичное число в его шестнадцатеричное представление с ведущими нулями:

Function DecHex(myDec As Long) As String

    DecHex = Right(«00000000» & Hex(myDec), 8)

End Function

Пример 3
Пользовательская функция, преобразующая шестнадцатеричное число в десятичное с помощью префикса &H:

Function HexDec(myHex As String) As Long

    HexDec = «&H» & myHex

End Function

Результат работы функций DecHex и HexDec:

Функция DecHex вставлена в ячейки второго столбца, а HexDec – в ячейки третьего.
Пример 4
Пользовательская функция, преобразующая указанные значения насыщенности красного, зеленого и синего цветов в шестнадцатеричный HTML-код цвета:

Function HexColor(red As Byte, green As Byte, blue As Byte) As String

    HexColor = «#» & Right(«00» & Hex(red), 2) & Right(«00» & Hex(green), 2) & Right(«00» & Hex(blue), 2)

End Function

Результат работы функции HexColor:

Функция HexColor вставлена в ячейки четвертого столбца.


As mentioned earlier, the formula =DEC2HEX(A1) converts to hex, and DEC2HEX(A1,8) converts to hex with 0 prefix to denote 32 bits. While adding the leading 0’s makes the numbers more readable, especially if you use a fixed point font, the hex and decimal versions can get mixed up when all of the digits in the number happen to be 0-9 (e.g. 327701=50015).

An improvement is to add the «0x» prefix. There are 2 ways to do this. =»0x»&DEC2HEX(A1,8) will do the trick, but it changes the field to a text field, so it can no longer easily be used in formulas. Another method is to use a custom format. If you apply the custom format «0x»@ to the cell, then the value of the cell can still be used in an equation. Examples:

╔═══╦════════════════╦════════════╦═════════════════════════════╦═══════════════╗
║   ║       A        ║     B      ║                             ║               ║
╠═══╬════════════════╬════════════╬═════════════════════════════╬═══════════════╣
║ 1 ║                ║ Value      ║ Corresponding Formula       ║ Number Format ║
║ 2 ║ Decimal        ║ 11162790   ║ 11162790                    ║ General       ║
║ 3 ║ Hex            ║ AA54A6     ║ =DEC2HEX(B2)                ║ General       ║
║ 4 ║ leading 0's    ║ 00AA54A6   ║ =DEC2HEX(B2,8)              ║ General       ║
║ 5 ║ Text 0x prefix ║ 0x00AA54A6 ║ =DEC2HEX(B2,8)              ║ "0x"@         ║
║ 6 ║ Text 0x prefix ║ 0x00AA54A6 ║ ="0x" & DEC2HEX(B2,8)       ║ General       ║
║ 7 ║ Use B5         ║ AA54A600   ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ General       ║
║ 8 ║ Use B5         ║ 0xAA54A600 ║ =DEC2HEX(HEX2DEC(B5) * 256) ║ "0x"@         ║
║ 9 ║ Try to use B6  ║ #NUM!      ║ =DEC2HEX(HEX2DEC(B6) * 256) ║ General       ║
╚═══╩════════════════╩════════════╩═════════════════════════════╩═══════════════╝

However, large numbers with varying digits can still be hard to read, so I like to put commas into decimal numbers and «_»s into hex numbers. First you need to get the upper and lower 16 bits of the number. The upper 16 bits of a 32-bit number can be retrieved with = INT( A1 / 2^16 ). Dividing by 2^16 acts like a right shift of 16 bits, and the INT removes the fractional remainder. MOD can be used to get the lower 16 bits of any 32 or 64-bit number; =MOD(A1, 2^16). The MOD effectively gets the remainder back, which is the lower 16 bits. Here is a table that shows this in action.

╔═══╦═════════════╦═══════════════╦════════════════════════════════════╦═════════╗
║   ║      A      ║      B        ║                                    ║         ║
╠═══╬═════════════╬═══════════════╬════════════════════════════════════╬═════════╣
║ 1 ║             ║ Value         ║ Corresponding Formula              ║ Format  ║
║ 2 ║ Decimal     ║ 3,098,743,209 ║ 3098743209                         ║ #,##0   ║
║ 3 ║ Upper Bytes ║ B8B3          ║ =DEC2HEX(INT( B2/2^16 ), 4)        ║ General ║
║ 4 ║ Lower Bytes ║ 11A9          ║ =DEC2HEX(MOD( B2, 2^16 ))          ║ General ║
║ 5 ║ Full Number ║ 0xB8B3_11A9   ║ ="0x" & DEC2HEX(INT( B2/2^16 ), 4) ║ General ║
║   ║             ║               ║ & "_" & DEC2HEX(MOD(B2, 2^16), 4)  ║         ║
╚═══╩═════════════╩═══════════════╩════════════════════════════════════╩═════════╝

BTW, I have to give a big thanks to https://ozh.github.io/ascii-tables/. I used that link to create the ASCII text tables. I just copied the table from my excel spreadsheet into its Input section and it automatically created the nice unicode text layout.



  • Excel 365


  • Excel 2021


  • Excel 2019


  • Excel 2016




  • February 12, 2022



  • No Comments

It’s unusual to need to work with Hexadecimal values in Excel, but on these rare occasions it can be challenging to figure out how Excel deals with values of this kind. If you simply enter a value like 0xABCDEF78 Excel will treat it as text and won’t recognize it as a numeric value.

What is Hexadecimal?

Hexadecimal (or Hex for short) is a counting system that uses 16 symbols as opposed to the 10 symbols used in the Decimal counting system that we use more often. Hexadecimal uses the letters A-F as well as the numbers 0-9.

Hexadecimal is most often used by computer systems, though it is also used in some advanced mathematical calculations outside of the world of computing.

Converting Hexadecimal values to Decimal in Excel

Excel won’t recognize a Hexadecimal value, but there is a function in its function library that will convert Hexadecimal values into Decimals: the HEX2DEC function.

For example: =HEX2DEC(“FF”) will return 255 – the decimal conversion of the Hexadecimal value FF.

If you’re unfamiliar with Excel functions and formulas you might benefit from our completely free Basic Skills E-book, which will introduce you to the basics of formulas and functions.

Dealing with 0x prefixes

Many programming languages prefix Hexadecimal values with 0x. For example 0xFF instead of just FF.

The HEX2DEC function won’t recognize a Hex value that has a 0x prefix so you will need to strip away the prefixes before you can convert the values.

There are a few different ways you could do this, including Flash Fill, Text To Columns and even Find & Replace, but a formula offers the most long-term solution because it will automatically recalculate. This formula will remove the 0x prefixes:

=RIGHT(A2,LEN(A2)-2)

All of the options mentioned above (as well as the RIGHT and LEN functions) are explained in depth in our Expert Skills Books and E-books.

A working example

You can download an example workbook showing the above functions and formulas in action.

Other counting systems supported by Excel

As well as the HEX2DEC function for Hex values, Excel also contains functions to convert values from Binary (Base 2) and Octal (Base 8) . These are supported by the BIN2DEC and OCT2DEC.

There are also functions to convert each of these counting systems to the other. For example you can convert an Octal value into a Hex value using the OCT2HEX function.

These are the only up-to-date Excel books currently published and includes the new Dynamic Arrays features.

They are also the only books that will teach you absolutely every Excel skill including Power Pivot, OLAP and DAX.

Some of the things you will learn

Share this article

Recent Articles

Leave a Reply

Понравилась статья? Поделить с друзьями:
  • Excel number of years
  • Excel number of selected rows
  • Excel number of rows with values
  • Excel number of days from date of
  • Excel number formatting codes