prgNbr="11"
parseInt(prgNbr);
prgNbr.toInteger(16);
Is there a faster direct way to do the two last steps?
prgNbr="11"
parseInt(prgNbr);
prgNbr.toInteger(16);
Is there a faster direct way to do the two last steps?
On Thursday, June 17, 2021 at 4:28:57 PM UTC-5, jonas.t...@gmail.com wrote:Great suggestion Michael had no idea parseInt had base as parameter.
prgNbr="11"
parseInt(prgNbr);
prgNbr.toInteger(16);
Is there a faster direct way to do the two last steps?parseInt(prgNbr,16)
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt>
Jonas Thornvall wrote:A numeric "decimal" string to hexdecimal string.
prgNbr="11"
parseInt(prgNbr);
prgNbr.toInteger(16);
Is there a faster direct way to do the two last steps?It might help if you told us what that was supposed to do, as it's not working code.
If you want to parse `11` as though it is a hexadecimal string and
thus should return the number 17, there's one answer. If you want
to return the hexadecimal equivalent of the decimal number 11, namely
`b`, then there's a different answer.
What are you trying to do?
-- Scott
fredag 18 juni 2021 kl. 14:59:24 UTC+2 skrev sc...@sauyet.com:
Jonas Thornvall wrote:
prgNbr="11"
parseInt(prgNbr);
prgNbr.toInteger(16);
What are you trying to do?
A numeric "decimal" string to hexdecimal string.
So Michales suggestion did not work out, it gives a hexadecimal number
not string.
Jonas Thörnvall <jonas.thornvall@gmail.com> writes:
fredag 18 juni 2021 kl. 14:59:24 UTC+2 skrev sc...@sauyet.com:
Jonas Thornvall wrote:
prgNbr="11"
parseInt(prgNbr);
prgNbr.toInteger(16);
What are you trying to do?
A numeric "decimal" string to hexdecimal string.
So Michales suggestion did not work out, it gives a hexadecimal number
not string.
parseInt(prgNbr).toString(16)
Technically, parseInt(prgNbr, 16) doesn't give a hexadecimal number
(there is not such thing). It gives a number by interpreting the string
as hexadecimal digits.
On Wednesday, June 30, 2021 at 5:51:16 PM UTC-5, Thomas 'PointedEars' Lahn wrote:
parseInt() should not be called without a radix value because then the
interpretation of the string depends on its prefix. This is a FAQ.
The FAQ should be updated. This now depends on the browser version.
With the following:
parseInt("070")
I see these results:
Brave (Chromium 91): 70
Firefox : 89: 70
IE 11: 70
IE 10: 70
IE 9: 70
IE 8: 56
IE 7: 56
IE 5: 56
parseInt() should not be called without a radix value because then the interpretation of the string depends on its prefix. This is a FAQ.
[…] I don't know if you are specifically talking about the 0 prefix
(not specified in ECMA-262) […]
On Wednesday, June 30, 2021 at 5:51:16 PM UTC-5, Thomas 'PointedEars' Lahn wrote:
parseInt() should not be called without a radix value because then the
interpretation of the string depends on its prefix. This is a FAQ.
The FAQ should be updated.
This now depends on the browser version.
With the following:
parseInt("070")
I see these results:
Brave (Chromium 91): 70
Firefox : 89: 70
IE 11: 70
IE 10: 70
IE 9: 70
IE 8: 56
IE 7: 56
IE 5: 56
<https://codepen.io/mlhaufe/pen/jOmERVg?editors=1000>
(When testing on older browsers use the debug view)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 335 |
Nodes: | 16 (2 / 14) |
Uptime: | 148:25:18 |
Calls: | 7,411 |
Calls today: | 1 |
Files: | 12,670 |
Messages: | 5,613,100 |