hex string to integer

user3206440

how to convert a hex string to integer? Postgres way of doing this is here

Adding sample input and output tables below.

table1

+---------+
| hex_val |
+---------+
| 00ff    |
| 00b0    |
| 8000    |
| 0050    |
+---------+

output

+---------+
| int_val |
+---------+
|     255 |
|     176 |
|   32768 |
|      80 |
+---------+
ScottMcG

You can use string_to_int to do this, specifying 16 as the base as the second parameter:

select string_to_int('8000',16);
 STRING_TO_INT 
---------------
         32768
(1 row)

This is documented here.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Addition of an integer with an hex string

From Dev

Python - convert from hex integer to hex string

From Dev

Convert integer to hex string in Groovy

From Dev

Convert an array of integer into a string of HEX

From Dev

How to convert a hex string to an integer?

From Dev

How to convert a hex string to an integer?

From Dev

converting 4byte hex string to integer

From Dev

Swift Convert Hex String or Character to Integer

From Dev

Best way to convert Hex string file to integer

From Dev

Swift Convert Integer to 2 character Hex String

From Dev

Swift Convert Hex String or Character to Integer

From Dev

hex to binary string and integer harmony needed

From Dev

Pythonic way to convert an integer into a hex-escaped string

From Dev

Pythonic way to convert an integer into a hex-escaped string

From Dev

Why string with hex format number convert to correct integer value? PHP

From Dev

Hex string to hex char[]

From Dev

Hex to integer (4 bytes)

From Dev

Hex to integer (4 bytes)

From Dev

Why does Ruby convert integer to octal-escaped string instead of hex-escaped one?

From Dev

Convert a hex string to a hex int

From Dev

Java String to hex string

From Dev

insert array of hex codes into an integer

From Dev

How to convert integer to hex notation?

From Dev

Big Integer and Hex Strings in java

From Dev

Array of chars in hex format to integer?

From Dev

Byte(dec)/Integer to Byte(hex)

From Dev

Color Conversion from Integer to Hex?

From Dev

Integer executing as a string and not an integer?

From Java

Convert string to HEX in R