Hex String
Hex String also is known as the hexadecimal string is a string of hexadecimal digits i.e. base 16 numbers.
Example:
string = "49AD1"
Long Integers
Long integers are storages for large integer values. It can store 64-bit signed integer value. The maximum value it can store is 9223372036854775807.
Convert hex string to long in Scala
We can convert a hex string to long in Scala by following these steps,
- Step1: We will convert the hex string to integer values using the parseInt() method.
- Step2: Then, we will convert this integer value to long value using the toLong method.
Program to convert hex string to long in Scala
Output:
Explanation:
In the above code, we have created a hexadecimal string named hexString. Then we have converted hexString to integer value using the parseInt() method of the Integer class and store it to intVal. This intVal is converted to a Long Integer value using the toLong method and prints the value using println method.
need an explanation for this answer? contact us directly to get an explanation for this answer