Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Life is a garment we continuously alter, but which never seems to fit." -- David McCord


devel / comp.lang.javascript / Re: Decimal numeric string to hexadecimal numeric string?

SubjectAuthor
* Decimal numeric string to hexadecimal numeric string?Jonas Thörnvall
+* Re: Decimal numeric string to hexadecimal numeric string?Michael Haufe (TNO)
|`- Re: Decimal numeric string to hexadecimal numeric string?Jonas Thörnvall
`* Re: Decimal numeric string to hexadecimal numeric string?Scott Sauyet
 `* Re: Decimal numeric string to hexadecimal numeric string?Jonas Thörnvall
  `* Re: Decimal numeric string to hexadecimal numeric string?Ben Bacarisse
   `* Re: Decimal numeric string to hexadecimal numeric string?Thomas 'PointedEars' Lahn
    `* Re: Decimal numeric string to hexadecimal numeric string?Michael Haufe (TNO)
     +* Re: Decimal numeric string to hexadecimal numeric string?Ben Bacarisse
     |`- Re: Decimal numeric string to hexadecimal numeric string?Thomas 'PointedEars' Lahn
     `- Re: Decimal numeric string to hexadecimal numeric string?Thomas 'PointedEars' Lahn

1
Decimal numeric string to hexadecimal numeric string?

<d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17107&group=comp.lang.javascript#17107

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:622a:118a:: with SMTP id m10mr7197879qtk.186.1623965333068; Thu, 17 Jun 2021 14:28:53 -0700 (PDT)
X-Received: by 2002:a54:4e10:: with SMTP id a16mr12651452oiy.48.1623965332761; Thu, 17 Jun 2021 14:28:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Thu, 17 Jun 2021 14:28:52 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=84.217.163.187; posting-account=kxPkPAoAAACjJi8w0gL9bnyznPzdw9HW
NNTP-Posting-Host: 84.217.163.187
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com>
Subject: Decimal numeric string to hexadecimal numeric string?
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Thu, 17 Jun 2021 21:28:53 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 5
 by: Jonas Thörnvall - Thu, 17 Jun 2021 21:28 UTC

prgNbr="11"

parseInt(prgNbr);
prgNbr.toInteger(16);

Is there a faster direct way to do the two last steps?

Re: Decimal numeric string to hexadecimal numeric string?

<04530eb5-144c-4f82-855a-60dabfa3cb26n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17109&group=comp.lang.javascript#17109

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a05:620a:91c:: with SMTP id v28mr7445668qkv.249.1623991110731;
Thu, 17 Jun 2021 21:38:30 -0700 (PDT)
X-Received: by 2002:a05:6808:15a7:: with SMTP id t39mr5811955oiw.176.1623991110387;
Thu, 17 Jun 2021 21:38:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Thu, 17 Jun 2021 21:38:30 -0700 (PDT)
In-Reply-To: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:63e1:1820:1474:ec3:c08c:d0f0;
posting-account=hYRygAoAAABkmvJVmPilz9Q1TOjgPQAq
NNTP-Posting-Host: 2600:1700:63e1:1820:1474:ec3:c08c:d0f0
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <04530eb5-144c-4f82-855a-60dabfa3cb26n@googlegroups.com>
Subject: Re: Decimal numeric string to hexadecimal numeric string?
From: tno@thenewobjective.com (Michael Haufe (TNO))
Injection-Date: Fri, 18 Jun 2021 04:38:30 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael Haufe (TNO) - Fri, 18 Jun 2021 04:38 UTC

On Thursday, June 17, 2021 at 4:28:57 PM UTC-5, jonas.t...@gmail.com wrote:
> 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>

Re: Decimal numeric string to hexadecimal numeric string?

<233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17111&group=comp.lang.javascript#17111

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:ae9:f309:: with SMTP id p9mr9416034qkg.363.1624021157892;
Fri, 18 Jun 2021 05:59:17 -0700 (PDT)
X-Received: by 2002:a9d:7356:: with SMTP id l22mr735670otk.2.1624021157629;
Fri, 18 Jun 2021 05:59:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Fri, 18 Jun 2021 05:59:17 -0700 (PDT)
In-Reply-To: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=170.202.22.102; posting-account=jEz2WAoAAABPN6KvjkIr_ZIYJY4YFml9
NNTP-Posting-Host: 170.202.22.102
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com>
Subject: Re: Decimal numeric string to hexadecimal numeric string?
From: scott@sauyet.com (Scott Sauyet)
Injection-Date: Fri, 18 Jun 2021 12:59:17 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Scott Sauyet - Fri, 18 Jun 2021 12:59 UTC

Jonas Thornvall wrote:

> 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

Re: Decimal numeric string to hexadecimal numeric string?

<4ed96b55-8d49-49fe-8be9-94575f4a8a7dn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17113&group=comp.lang.javascript#17113

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a0c:aa13:: with SMTP id d19mr9432070qvb.3.1624088367601; Sat, 19 Jun 2021 00:39:27 -0700 (PDT)
X-Received: by 2002:a9d:7610:: with SMTP id k16mr12535260otl.32.1624088367374; Sat, 19 Jun 2021 00:39:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Sat, 19 Jun 2021 00:39:27 -0700 (PDT)
In-Reply-To: <04530eb5-144c-4f82-855a-60dabfa3cb26n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=84.217.163.187; posting-account=kxPkPAoAAACjJi8w0gL9bnyznPzdw9HW
NNTP-Posting-Host: 84.217.163.187
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com> <04530eb5-144c-4f82-855a-60dabfa3cb26n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4ed96b55-8d49-49fe-8be9-94575f4a8a7dn@googlegroups.com>
Subject: Re: Decimal numeric string to hexadecimal numeric string?
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Sat, 19 Jun 2021 07:39:27 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 11
 by: Jonas Thörnvall - Sat, 19 Jun 2021 07:39 UTC

fredag 18 juni 2021 kl. 06:38:35 UTC+2 skrev Michael Haufe (TNO):
> On Thursday, June 17, 2021 at 4:28:57 PM UTC-5, jonas.t...@gmail.com wrote:
> > 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>
Great suggestion Michael had no idea parseInt had base as parameter.

Re: Decimal numeric string to hexadecimal numeric string?

<db65730d-8ad2-478f-938b-b8398d62cdadn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17114&group=comp.lang.javascript#17114

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a37:6196:: with SMTP id v144mr6686125qkb.225.1624088733422; Sat, 19 Jun 2021 00:45:33 -0700 (PDT)
X-Received: by 2002:a05:6830:9:: with SMTP id c9mr1408690otp.195.1624088733186; Sat, 19 Jun 2021 00:45:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Sat, 19 Jun 2021 00:45:32 -0700 (PDT)
In-Reply-To: <233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=84.217.163.187; posting-account=kxPkPAoAAACjJi8w0gL9bnyznPzdw9HW
NNTP-Posting-Host: 84.217.163.187
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com> <233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <db65730d-8ad2-478f-938b-b8398d62cdadn@googlegroups.com>
Subject: Re: Decimal numeric string to hexadecimal numeric string?
From: jonas.thornvall@gmail.com (Jonas Thörnvall)
Injection-Date: Sat, 19 Jun 2021 07:45:33 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 21
 by: Jonas Thörnvall - Sat, 19 Jun 2021 07:45 UTC

fredag 18 juni 2021 kl. 14:59:24 UTC+2 skrev sc...@sauyet.com:
> Jonas Thornvall wrote:
>
> > 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
A numeric "decimal" string to hexdecimal string.
So Michales suggestion did not work out, it gives a hexadecimal number not string.

Re: Decimal numeric string to hexadecimal numeric string?

<87fsxegmpj.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17115&group=comp.lang.javascript#17115

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.javascript
Subject: Re: Decimal numeric string to hexadecimal numeric string?
Date: Sat, 19 Jun 2021 11:42:16 +0100
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <87fsxegmpj.fsf@bsb.me.uk>
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com>
<233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com>
<db65730d-8ad2-478f-938b-b8398d62cdadn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="a7f27449a8e1d29c2e31ba58df9df84b";
logging-data="14269"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YnvjLc1q32RbpTc6mTebA4otW6oZpdnk="
Cancel-Lock: sha1:CvVI6cX7AOFUUgiXNsJ6IsqZtsc=
sha1:2Qz+ZqV/BYI6l3EVPO6DuWyHT9w=
X-BSB-Auth: 1.66ff9686bcac81ea8e81.20210619114216BST.87fsxegmpj.fsf@bsb.me.uk
 by: Ben Bacarisse - Sat, 19 Jun 2021 10:42 UTC

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.

--
Ben.

Re: Decimal numeric string to hexadecimal numeric string?

<20837730.9tcgPO3Tcr@PointedEars.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17153&group=comp.lang.javascript#17153

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!aioe.org!news.mb-net.net!open-news-network.org!.POSTED.178.197.216.189!not-for-mail
From: PointedEars@web.de (Thomas 'PointedEars' Lahn)
Newsgroups: comp.lang.javascript
Subject: Re: Decimal numeric string to hexadecimal numeric string?
Date: Thu, 01 Jul 2021 00:51:08 +0200
Organization: PointedEars Software (PES)
Lines: 36
Message-ID: <20837730.9tcgPO3Tcr@PointedEars.de>
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com> <233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com> <db65730d-8ad2-478f-938b-b8398d62cdadn@googlegroups.com> <87fsxegmpj.fsf@bsb.me.uk>
Reply-To: Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8Bit
Injection-Info: gwaiyur.mb-net.net; posting-host="178.197.216.189";
logging-data="31527"; mail-complaints-to="abuse@open-news-network.org"
User-Agent: KNode/4.14.10
Cancel-Lock: sha1:6ufBRkdsdvh28lOKYuMfpW3DDEg=
X-User-ID: U2FsdGVkX18bQMGisYSZHu1F1VebPhyukQmX4kfYt4OrQMysVXawKQ==
X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
 by: Thomas 'Pointed - Wed, 30 Jun 2021 22:51 UTC

Ben Bacarisse wrote:

> 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);

Neither of these statements do anything useful as the argument is a
primitive value that cannot be modified.

>>> 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.

Instead:

let hex = parseInt(prgNbr, 10).toString(16);

parseInt() should not be called without a radix value because then the
interpretation of the string depends on its prefix. This is a FAQ.

--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Re: Decimal numeric string to hexadecimal numeric string?

<0d312dec-5b2c-4a8b-9bb0-fe0c1fd867f9n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17154&group=comp.lang.javascript#17154

  copy link   Newsgroups: comp.lang.javascript
X-Received: by 2002:a0c:b921:: with SMTP id u33mr40094204qvf.12.1625099958810;
Wed, 30 Jun 2021 17:39:18 -0700 (PDT)
X-Received: by 2002:a9d:8a3:: with SMTP id 32mr11484874otf.277.1625099958297;
Wed, 30 Jun 2021 17:39:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.javascript
Date: Wed, 30 Jun 2021 17:39:18 -0700 (PDT)
In-Reply-To: <20837730.9tcgPO3Tcr@PointedEars.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:63e1:1820:c4e4:ee31:12e9:e75;
posting-account=hYRygAoAAABkmvJVmPilz9Q1TOjgPQAq
NNTP-Posting-Host: 2600:1700:63e1:1820:c4e4:ee31:12e9:e75
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com>
<233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com> <db65730d-8ad2-478f-938b-b8398d62cdadn@googlegroups.com>
<87fsxegmpj.fsf@bsb.me.uk> <20837730.9tcgPO3Tcr@PointedEars.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0d312dec-5b2c-4a8b-9bb0-fe0c1fd867f9n@googlegroups.com>
Subject: Re: Decimal numeric string to hexadecimal numeric string?
From: tno@thenewobjective.com (Michael Haufe (TNO))
Injection-Date: Thu, 01 Jul 2021 00:39:18 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael Haufe (TNO) - Thu, 1 Jul 2021 00:39 UTC

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)

Re: Decimal numeric string to hexadecimal numeric string?

<878s2qkgci.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17155&group=comp.lang.javascript#17155

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.javascript
Subject: Re: Decimal numeric string to hexadecimal numeric string?
Date: Thu, 01 Jul 2021 01:50:05 +0100
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <878s2qkgci.fsf@bsb.me.uk>
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com>
<233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com>
<db65730d-8ad2-478f-938b-b8398d62cdadn@googlegroups.com>
<87fsxegmpj.fsf@bsb.me.uk> <20837730.9tcgPO3Tcr@PointedEars.de>
<0d312dec-5b2c-4a8b-9bb0-fe0c1fd867f9n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="a2d8b1c21ccbe83bdb1b6c6beabf5900";
logging-data="31250"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Ib8cVexKxBP7HtNH5aofbYXm4I4+pDLM="
Cancel-Lock: sha1:CggZmJc1lg7Sz7D9A3lHXE7gHBQ=
sha1:mJR4xNHQrIJNaI+MvrtzM2bba3I=
X-BSB-Auth: 1.cb67da99e8512fb7f4cf.20210701015005BST.878s2qkgci.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 1 Jul 2021 00:50 UTC

"Michael Haufe (TNO)" <tno@thenewobjective.com> writes:

> 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

But parseInt("0x70") should be 112 (and it is where I was able to test
it). I don't know if you are specifically talking about the 0 prefix
(not specified in ECMA-262) or about prefixes in general.

--
Ben.

Re: Decimal numeric string to hexadecimal numeric string?

<7969540.pbqncKrJha@PointedEars.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17158&group=comp.lang.javascript#17158

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!aioe.org!news.mb-net.net!open-news-network.org!.POSTED.178.197.216.189!not-for-mail
From: PointedEars@web.de (Thomas 'PointedEars' Lahn)
Newsgroups: comp.lang.javascript
Subject: Re: Decimal numeric string to hexadecimal numeric string?
Date: Thu, 01 Jul 2021 12:43:53 +0200
Organization: PointedEars Software (PES)
Lines: 85
Message-ID: <7969540.pbqncKrJha@PointedEars.de>
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com> <233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com> <db65730d-8ad2-478f-938b-b8398d62cdadn@googlegroups.com> <87fsxegmpj.fsf@bsb.me.uk> <20837730.9tcgPO3Tcr@PointedEars.de> <0d312dec-5b2c-4a8b-9bb0-fe0c1fd867f9n@googlegroups.com>
Reply-To: Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8Bit
Injection-Info: gwaiyur.mb-net.net; posting-host="178.197.216.189";
logging-data="9755"; mail-complaints-to="abuse@open-news-network.org"
User-Agent: KNode/4.14.10
Cancel-Lock: sha1:FldLylVTLrMtNyLTHlNMQwRwgAc=
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
X-User-ID: U2FsdGVkX19ajDe0i4AENemgcD5Wa0FKhyI4CbzTLlMu5UMEXcaldA==
X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
 by: Thomas 'Pointed - Thu, 1 Jul 2021 10:43 UTC

Michael Haufe (TNO) wrote:

> 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.

I am still waiting for, and am looking forward to, your pull requests
*shrug*

<https://github.com/PointedEars/FAQ-cljs>

> This now depends on the browser version.

Not really, see below.
> 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)

The interpretation of octal string literals by parseInt() without “radix”
argument *always* depended on the "browser version", more precisely the
ECMAScript implementation supported, and the version of the script engine
used, by the runtime environment. That is *the* reason why the FAQ
recommends to specify the “radix” argument since time immemorial:

<http://PointedEars.de/scripts/faq/cljs/#parseIntBase>

Compare

<https://www.ecma-international.org/wp-content/uploads/ECMA-262_3rd_edition_december_1999.pdf#page=89>

with

<https://www.ecma-international.org/wp-content/uploads/ECMA-262_5th_edition_december_2009.pdf#page=114>

Microsoft Internet Explorer/MSHTML 5.0 through 8.0 support/use Microsoft
JScript 5.0 through 5.8.x which implement ECMAScript Ed. 3/5.x¹; whereas
IE/MSHTML 9 and 10 support/use JScript 9.0 and 10.0.x, which implement
ECMAScript Ed. 5.x.

The latest version of Firefox supports Mozilla JavaScript 78 and later
(I have only Firefox 78 here), and uses a recent version of Mozilla
SpiderMonkey, which implements ECMAScript 2020 or later.

Chromium 91 supports Google JavaScript 9.0.257.29 or later, and uses Google
V8, which implements ECMAScript 2020 or later.

So your results are unsurprising (but valuable²) to me. See also:

<http://PointedEars.de/es-matrix#version-info>

BTW, it is July in Europe now, so ECMAScript 2021 was "released" :-o

<https://262.ecma-international.org/>

_______
¹ Here we can see that an ECMAScript implementation does not always meet
what is unambiguously specified in the Edition that it claims to
implement.
² Strangely enough, I do not have a test case for that in the ECMAScript
Support Matrix yet: <http://PointedEars.de/es-matrix/?filter=parseInt>
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Re: Decimal numeric string to hexadecimal numeric string?

<5665699.fGT1HTpLYz@PointedEars.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17159&group=comp.lang.javascript#17159

  copy link   Newsgroups: comp.lang.javascript
Path: i2pn2.org!i2pn.org!aioe.org!news.mb-net.net!open-news-network.org!.POSTED.178.197.216.189!not-for-mail
From: PointedEars@web.de (Thomas 'PointedEars' Lahn)
Newsgroups: comp.lang.javascript
Subject: Re: Decimal numeric string to hexadecimal numeric string?
Date: Thu, 01 Jul 2021 12:46:24 +0200
Organization: PointedEars Software (PES)
Lines: 12
Message-ID: <5665699.fGT1HTpLYz@PointedEars.de>
References: <d210bffe-abab-448a-b36b-e1b27f3e25c0n@googlegroups.com> <233183ba-98dc-47d5-84f6-bd3beef1e793n@googlegroups.com> <db65730d-8ad2-478f-938b-b8398d62cdadn@googlegroups.com> <87fsxegmpj.fsf@bsb.me.uk> <20837730.9tcgPO3Tcr@PointedEars.de> <0d312dec-5b2c-4a8b-9bb0-fe0c1fd867f9n@googlegroups.com> <878s2qkgci.fsf@bsb.me.uk>
Reply-To: Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 8Bit
Injection-Info: gwaiyur.mb-net.net; posting-host="178.197.216.189";
logging-data="9755"; mail-complaints-to="abuse@open-news-network.org"
User-Agent: KNode/4.14.10
Cancel-Lock: sha1:Ok5i6Sv+nv2VhJ7jVujy3IBHAMM=
X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
X-User-ID: U2FsdGVkX1/ULs4fKyNR9Lt7yF0/1goG/9/WVqfY8cOxtFYW7NDtRQ==
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
 by: Thomas 'Pointed - Thu, 1 Jul 2021 10:46 UTC

Ben Bacarisse wrote:

> […] I don't know if you are specifically talking about the 0 prefix
> (not specified in ECMA-262) […]

The triggering “0” prefix *was* specified in ECMA-262 until including
Edition 3, but the behavior was specified as implementation-dependent.

--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.


devel / comp.lang.javascript / Re: Decimal numeric string to hexadecimal numeric string?

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor