Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Javascript: dec to hex + slicing
#2
Hi,
The input value is too big.
the "toString(16)" is not working for values with more than 16 digits.

you can use the "slice" before the conversion to hex. 
check the code below. The result is not correct but I hope to help you

Code:
var inputValue = +1224277079131226000.0;
var inputsliced = inputValue.toString().slice(0,-4);
var n= +inputsliced;
var hex=n.toString(16).toUpperCase();
res = '{"tag":"outputTag", "value":"'+ hex+ '"}';
Reply


Messages In This Thread
Javascript: dec to hex + slicing - by Dkyndt - 04-19-2023, 09:02 PM
RE: Javascript: dec to hex + slicing - by iliaslamprou - 04-20-2023, 12:43 AM
RE: Javascript: dec to hex + slicing - by Dkyndt - 04-20-2023, 06:50 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)