Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28309 > unrolled thread
| Started by | dddudeman <dddudeman9@gmail.com> |
|---|---|
| First post | 2015-07-06 22:24 -0400 |
| Last post | 2015-07-07 15:21 -0700 |
| Articles | 14 on this page of 54 — 10 participants |
Back to article view | Back to comp.lang.javascript
String to Base76 dddudeman <dddudeman9@gmail.com> - 2015-07-06 22:24 -0400
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-07 08:15 +0200
Re: String to Base76 dddudeman <dddudeman9@gmail.com> - 2015-07-07 13:12 -0400
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-07 19:20 +0200
Re: String to Base76 Wesley <dddudeman9@gmail.comREMOVETHIS> - 2015-07-07 13:23 -0400
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 00:17 +0200
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-08 09:02 +0200
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 11:53 +0200
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-08 12:14 +0200
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 12:28 +0200
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-08 17:27 +0200
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 18:19 +0200
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-08 19:08 +0200
Re: String to Base76 Gene Wirchenko <genew@telus.net> - 2015-07-09 10:48 -0700
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-09 22:06 +0200
Re: String to Base76 Gene Wirchenko <genew@telus.net> - 2015-07-09 14:18 -0700
Re: String to Base76 John Harris <niam@jghnorth.org.uk.invalid> - 2015-07-08 16:03 +0100
Re: String to Base76 Gene Wirchenko <genew@telus.net> - 2015-07-07 10:48 -0700
Re: String to Base76 Wesley <dddudeman9@gmail.comREMOVETHIS> - 2015-07-07 13:58 -0400
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-07 21:04 +0200
Re: String to Base76 Gene Wirchenko <genew@telus.net> - 2015-07-07 13:11 -0700
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-07 23:38 +0200
Re: String to Base76 Gene Wirchenko <genew@telus.net> - 2015-07-09 10:50 -0700
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-09 22:22 +0200
Re: String to Base76 Gene Wirchenko <genew@telus.net> - 2015-07-09 14:24 -0700
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-10 09:16 +0200
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 00:14 +0200
Re: String to Base76 Wesley <dddudeman9@gmail.comREMOVETHIS> - 2015-07-07 20:38 -0400
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 03:27 +0200
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-07 12:30 +0200
Re: String to Base76 dddudeman <dddudeman9@gmail.com> - 2015-07-07 13:16 -0400
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-07 19:26 +0200
Re: String to Base76 Wesley <dddudeman9@gmail.comREMOVETHIS> - 2015-07-07 13:54 -0400
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-07 21:17 +0200
Re: String to Base76 Wesley <dddudeman9@gmail.comREMOVETHIS> - 2015-07-07 16:57 -0400
Re: String to Base76 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-07-08 00:17 +0200
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 00:30 +0200
Re: String to Base76 Wesley <dddudeman9@gmail.comREMOVETHIS> - 2015-07-07 20:43 -0400
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 03:17 +0200
Re: String to Base76 Wesley Navaille <dddudeman9@gmail.com> - 2015-07-07 22:01 -0400
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 12:05 +0200
Re: String to Base76 Wesley Navaille <dddudeman9@gmail.com> - 2015-07-08 13:50 -0400
Re: String to Base76 Scott Sauyet <scott.sauyet@gmail.com> - 2015-07-08 19:05 -0700
Re: String to Base76 Wesley Navaille <dddudeman9@gmail.com> - 2015-07-08 22:17 -0400
Re: String to Base76 Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-08 00:22 +0200
Re: String to Base76 wolfgang zeidler <invalid@invalid.invalid> - 2015-07-07 20:02 +0200
Re: String to Base76 Wesley <dddudeman9@gmail.comREMOVETHIS> - 2015-07-07 14:08 -0400
Re: String to Base76 "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-07-07 12:01 -0700
Re: String to Base76 Gene Wirchenko <genew@telus.net> - 2015-07-07 13:05 -0700
Re: String to Base76 "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-07-07 13:24 -0700
Re: String to Base76 Wesley <dddudeman9@gmail.comREMOVETHIS> - 2015-07-07 17:10 -0400
Re: String to Base76 "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-07-07 14:53 -0700
Re: String to Base76 wolfgang zeidler <invalid@invalid.invalid> - 2015-07-07 23:46 +0200
Re: String to Base76 Gene Wirchenko <genew@telus.net> - 2015-07-07 15:21 -0700
Page 3 of 3 — ← Prev page 1 2 [3]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2015-07-08 12:05 +0200 |
| Message-ID | <11403798.qR2YRpXdMr@PointedEars.de> |
| In reply to | #28355 |
Wesley Navaille wrote: > On 7/7/2015 21:17, Thomas 'PointedEars' Lahn wrote: >>> […] I meant to encode discussions on bulletin boards mainly to keep >>> [other people from being able to easily understand some things. >> >> One cannot help you if you do not state your purpose clearly. This is >> not a guessing game. RTFFAQ and stop wasting our time. > > It's pretty simple to figure out what I was meaning to encode. I planned > to just encode messages on a bulletin board (which I've already > mentioned) that I assist in managing so some casual viewers wouldn't be > able to view some of them as easily(which I've already mentioned). It > wasn't even my idea, […] Better, but you still have not answered the crucial question: Why? What is the matter with those messages that they need to be encoded using a new code? >>> I regret posting this thread. >> You should regret other things instead. > > Posting under the wrong name than you wanted just to feed your autism? > Yeah, I regret that too. I am beginning to understand those people showing up at your house. -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Wesley Navaille <dddudeman9@gmail.com> |
|---|---|
| Date | 2015-07-08 13:50 -0400 |
| Message-ID | <mnjnqr$tbd$1@dont-email.me> |
| In reply to | #28361 |
On 7/8/2015 06:05, Thomas 'PointedEars' Lahn wrote: > Wesley Navaille wrote: > >> On 7/7/2015 21:17, Thomas 'PointedEars' Lahn wrote: >>>> […] I meant to encode discussions on bulletin boards mainly to keep >>>> [other people from being able to easily understand some things. >>> >>> One cannot help you if you do not state your purpose clearly. This is >>> not a guessing game. RTFFAQ and stop wasting our time. >> >> It's pretty simple to figure out what I was meaning to encode. I planned >> to just encode messages on a bulletin board (which I've already >> mentioned) that I assist in managing so some casual viewers wouldn't be >> able to view some of them as easily(which I've already mentioned). It >> wasn't even my idea, […] > > Better, but you still have not answered the crucial question: Why? What is > the matter with those messages that they need to be encoded using a new > code? > It's not even anything special about these messages, just on IRC I was working on my bot and somebody said that I should put base64 encoding as a function of it, and then other people said that I should try to put something new, that nothing else has. I don't even really know why they wanted to encode some messages. People have done it in the past when they wanted to say some things slightly out of the public eye but still be understood by people who cared enough to decode it.
[toc] | [prev] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2015-07-08 19:05 -0700 |
| Message-ID | <f1e16c1b-c3f4-4a8f-8efe-3d3acce586ec@googlegroups.com> |
| In reply to | #28370 |
Wesley Navaille wrote: > It's not even anything special about these messages, just on IRC I was > working on my bot and somebody said that I should put base64 encoding as > a function of it, and then other people said that I should try to put > something new, that nothing else has. I don't even really know why they > wanted to encode some messages. People have done it in the past when > they wanted to say some things slightly out of the public eye but still > be understood by people who cared enough to decode it. For that use, I would suggest that Base64 is significantly better. If the point is to encode it so that the content is not obvious, but to still make it easy to decode, then a commonly-used encoding is not only simpler to implement, but also easier for your users, who might choose to decode it through another means than your decoder (perhaps a browser plug-in, for instance.) If the point is simply to play around with simple encodings as a learning experience or some such, obviously do as you like. Note that the six-bit output of Base64 was chosen carefully. The whole point is that one can, by increasing an arbitrary stream of bytes by only 33%, encode it with only a simple subset of the common ASCII characters. Four six-bit characters precisely encodes three arbitrary eight-bit bytes. So that encoding has a real rationale; it's not arbitrary. -- Scott
[toc] | [prev] | [next] | [standalone]
| From | Wesley Navaille <dddudeman9@gmail.com> |
|---|---|
| Date | 2015-07-08 22:17 -0400 |
| Message-ID | <mnklhc$1cf$1@dont-email.me> |
| In reply to | #28371 |
On 7/8/2015 22:05, Scott Sauyet wrote: <snip> >If the point is simply to play around with simple encodings > as a learning experience or some such, obviously do as you like. I pretty much took this as an opportunity to do that, but I may still use base64. > Note that the six-bit output of Base64 was chosen carefully. The whole point > is that one can, by increasing an arbitrary stream of bytes by only 33%, > encode it with only a simple subset of the common ASCII characters. Four > six-bit characters precisely encodes three arbitrary eight-bit bytes. So that > encoding has a real rationale; it's not arbitrary. As I have been looking at other bases I have been noticing that they do not work as well as base64. ROT76 may be a better option.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2015-07-08 00:22 +0200 |
| Message-ID | <1919235.JL1bSv2PVq@PointedEars.de> |
| In reply to | #28327 |
Wesley wrote: > On 7/7/2015 13:26, Evertjan. wrote: >> dddudeman <dddudeman9@gmail.com> wrote […]: >>>>> Would I be best off using the base64 module >>>> What is "the" base64 module? >>> https://www.npmjs.com/package/base64 >> Why is that "the" base64 module? > > I guess I just called it that since it is the one simply titled "base64" > so I thought that it was the "one to use" or whatever. Your terminology, at least, is correct. “Evertjan.” has overlooked your reference to Node.js, and obviously does not know it. Please keep *all* attributions (and trim those that are longer than one line). -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | wolfgang zeidler <invalid@invalid.invalid> |
|---|---|
| Date | 2015-07-07 20:02 +0200 |
| Message-ID | <mnh46p$tc0$1@news.m-online.net> |
| In reply to | #28309 |
dddudeman wrote: > I am writing an IRC bot in node.js and I am trying to implement base76 > conversion. Similar to base64, but using a different number. It's a > stupid idea, but we want to use a base that isn't commonly used, not > really for security, but for privacy, if that makes any sense. The basic > idea that I have is to get the string and convert it to the ascii > character codes, then that string of numbers to base76 using a character > set that I made up. I think I'm going to use > "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+=/\><^-_%$[]*" > but I have no idea if that's actually what's used in that base. Would I > be best off using the base64 module and modifying that or making mine > implementation in js? Why of all things 76? It shout be much easier if you would use a square number like 81 or 100 as base. -- wzwz.de/mail
[toc] | [prev] | [next] | [standalone]
| From | Wesley <dddudeman9@gmail.comREMOVETHIS> |
|---|---|
| Date | 2015-07-07 14:08 -0400 |
| Message-ID | <mnh4g1$70l$1@dont-email.me> |
| In reply to | #28329 |
On 7/7/2015 14:02, wolfgang zeidler wrote: > dddudeman wrote: >> I am writing an IRC bot in node.js and I am trying to implement base76 >> conversion. Similar to base64, but using a different number. It's a >> stupid idea, but we want to use a base that isn't commonly used, not >> really for security, but for privacy, if that makes any sense. The basic >> idea that I have is to get the string and convert it to the ascii >> character codes, then that string of numbers to base76 using a character >> set that I made up. I think I'm going to use >> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+=/\><^-_%$[]*" >> >> but I have no idea if that's actually what's used in that base. Would I >> be best off using the base64 module and modifying that or making mine >> implementation in js? > > Why of all things 76? > > It shout be much easier if you would use a square number like 81 or 100 > as base. > Because the name of my website has 76 in it and we want to be special snowflakes. That's really that it. It doesn't matter if a different base would be better off.
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2015-07-07 12:01 -0700 |
| Message-ID | <52d00e41-2487-4799-9cf5-31682a43edfa@googlegroups.com> |
| In reply to | #28330 |
On Tuesday, July 7, 2015 at 1:08:28 PM UTC-5, Wesley wrote: > On 7/7/2015 14:02, wolfgang zeidler wrote: > > dddudeman wrote: > >> I am writing an IRC bot in node.js and I am trying to implement base76 > >> conversion. Similar to base64, but using a different number. It's a > >> stupid idea, but we want to use a base that isn't commonly used, not > >> really for security, but for privacy, if that makes any sense. The basic > >> idea that I have is to get the string and convert it to the ascii > >> character codes, then that string of numbers to base76 using a character > >> set that I made up. I think I'm going to use > >> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+=/\><^-_%$[]*" > >> > >> but I have no idea if that's actually what's used in that base. Would I > >> be best off using the base64 module and modifying that or making mine > >> implementation in js? > > > > Why of all things 76? > > > > It shout be much easier if you would use a square number like 81 or 100 > > as base. > > > > Because the name of my website has 76 in it and we want to be special > snowflakes. That's really that it. It doesn't matter if a different base > would be better off. Why not just use ROT76 then? Reference for ROT13: <https://en.wikipedia.org/wiki/ROT13>
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@telus.net> |
|---|---|
| Date | 2015-07-07 13:05 -0700 |
| Message-ID | <s7copa5b7t7p4f4fp5gkap21k9ctms897n@4ax.com> |
| In reply to | #28329 |
On Tue, 07 Jul 2015 20:02:03 +0200, wolfgang zeidler
<invalid@invalid.invalid> wrote:
>dddudeman wrote:
>> I am writing an IRC bot in node.js and I am trying to implement base76
>> conversion. Similar to base64, but using a different number. It's a
>> stupid idea, but we want to use a base that isn't commonly used, not
>> really for security, but for privacy, if that makes any sense. The basic
>> idea that I have is to get the string and convert it to the ascii
>> character codes, then that string of numbers to base76 using a character
>> set that I made up. I think I'm going to use
>> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+=/\><^-_%$[]*"
>> but I have no idea if that's actually what's used in that base. Would I
>> be best off using the base64 module and modifying that or making mine
>> implementation in js?
>
>Why of all things 76?
>
>It shout be much easier if you would use a square number like 81 or 100
>as base.
Why would that make it easier? Does 10 (a non-square) cause
problems?
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2015-07-07 13:24 -0700 |
| Message-ID | <b6442faf-569e-4298-b856-f8ea650ee454@googlegroups.com> |
| In reply to | #28334 |
On Tuesday, July 7, 2015 at 3:06:06 PM UTC-5, Gene Wirchenko wrote: > On Tue, 07 Jul 2015 20:02:03 +0200, wolfgang zeidler [...] > >It shout be much easier if you would use a square number like 81 or 100 > >as base. > > Why would that make it easier? Does 10 (a non-square) cause > problems? I would suspect instead that an encoding not based on a power of two would make it more complicated to map back and forth between representations: <https://en.wikipedia.org/wiki/Binary-to-text_encoding>
[toc] | [prev] | [next] | [standalone]
| From | Wesley <dddudeman9@gmail.comREMOVETHIS> |
|---|---|
| Date | 2015-07-07 17:10 -0400 |
| Message-ID | <mnhf4l$i1c$1@dont-email.me> |
| In reply to | #28336 |
On 7/7/2015 16:24, Michael Haufe (TNO) wrote: > On Tuesday, July 7, 2015 at 3:06:06 PM UTC-5, Gene Wirchenko wrote: >> On Tue, 07 Jul 2015 20:02:03 +0200, wolfgang zeidler > [...] > >>> It shout be much easier if you would use a square number like 81 or 100 >>> as base. >> >> Why would that make it easier? Does 10 (a non-square) cause >> problems? > > I would suspect instead that an encoding not based on a power of two would make it more complicated to map back and forth between representations: > > <https://en.wikipedia.org/wiki/Binary-to-text_encoding> > I'm not sure if this is exactly right, but I was kind of testing the idea just using simple online base converters and I had some trouble. For example: I found the ascii character codes of "Testing" which is 084 101 115 116 105 110 103 I then ran that through a base converter from base 10 to base 50, which was an arbitrary number. the website spit out HB9cRHLQei23 as the base 50 representation of 084101115116105110103 Then if you use the same tool to convert back it spits out 84101115116105110103 since it doesn't read the 0 as part of the string. That doesn't code back to the same text unless you put the leading 0 back. Maybe I'm going about this all wrong.
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2015-07-07 14:53 -0700 |
| Message-ID | <76e81002-af8c-4096-b54e-511fe59ef7e0@googlegroups.com> |
| In reply to | #28338 |
On Tuesday, July 7, 2015 at 4:10:08 PM UTC-5, Wesley wrote: > On 7/7/2015 16:24, Michael Haufe (TNO) wrote: > > On Tuesday, July 7, 2015 at 3:06:06 PM UTC-5, Gene Wirchenko wrote: > >> On Tue, 07 Jul 2015 20:02:03 +0200, wolfgang zeidler > > [...] > > > >>> It shout be much easier if you would use a square number like 81 or 100 > >>> as base. > >> > >> Why would that make it easier? Does 10 (a non-square) cause > >> problems? > > > > I would suspect instead that an encoding not based on a power of two would make it more complicated to map back and forth between representations: > > > > <https://en.wikipedia.org/wiki/Binary-to-text_encoding> > > > > I'm not sure if this is exactly right, but I was kind of testing the > idea just using simple online base converters and I had some trouble. > > For example: > > I found the ascii character codes of "Testing" which is > 084 101 115 116 105 110 103 > > I then ran that through a base converter from base 10 to base 50, which > was an arbitrary number. > > the website spit out HB9cRHLQei23 as the base 50 representation of > 084101115116105110103 > > Then if you use the same tool to convert back it spits out > 84101115116105110103 since it doesn't read the 0 as part of the string. > That doesn't code back to the same text unless you put the leading 0 > back. Maybe I'm going about this all wrong. Assuming a base 50 character set of: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN T e s t i n g //Text 084 101 115 116 105 110 103 //ASCII 01y 021 02f 02g 025 02a 023 //Base 50 if you drop the leading 0s, then you lose positional information.
[toc] | [prev] | [next] | [standalone]
| From | wolfgang zeidler <invalid@invalid.invalid> |
|---|---|
| Date | 2015-07-07 23:46 +0200 |
| Message-ID | <mnhhap$2l7$1@news.m-online.net> |
| In reply to | #28334 |
Gene Wirchenko wrote: > On Tue, 07 Jul 2015 20:02:03 +0200, wolfgang zeidler > <invalid@invalid.invalid> wrote: > >> dddudeman wrote: >>> I am writing an IRC bot in node.js and I am trying to implement base76 >>> conversion. Similar to base64, but using a different number. It's a >>> stupid idea, but we want to use a base that isn't commonly used, not >>> really for security, but for privacy, if that makes any sense. The basic >>> idea that I have is to get the string and convert it to the ascii >>> character codes, then that string of numbers to base76 using a character >>> set that I made up. I think I'm going to use >>> "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+=/\><^-_%$[]*" >>> but I have no idea if that's actually what's used in that base. Would I >>> be best off using the base64 module and modifying that or making mine >>> implementation in js? >> >> Why of all things 76? >> >> It shout be much easier if you would use a square number like 81 or 100 >> as base. > > Why would that make it easier? Does 10 (a non-square) cause > problems? > No, 10 causes no problem ( we talk about JavaScript ). JavaScript offers the opportunity to transform numbers to number_strings of base 2 to 36. Maybe/Likely 2, 4, 8, 16, 32 are faster than other bases, but I think that's not what we talking about. Causes base 76 any problem? That depends on how we define a 'problem'. 76 is outside the range of 2..36. Naturally I can write a programm which generates a base_76_string, but that's a lot of work. And this programm will surely be slow, it has to do a lot of calculations. It works, I wouldn't call it a "problem", but I will call it unnecessary difficult. The alternative: It's very easy to transform and re-transform a base_n_string to a base_m_string if m = n^k, n > 1, k > 0. Make sure that n_string.length mod k is zero, otherwise use padding. Divide the base_n_string into char groups of length k and produce for every group a char of base m. Popular example, bin to hex: '0000' -> '0' '0001' -> '1' ............. '1111' -> 'F' Example "81" for this thread: - Use JavaScript to transform each char to a base_9_digit_string. - Make sure that each digit_string has length 3, e.g. '42' --> '042'. - Connect this digit_strings to a number_string. - If the length of the number_string is odd: add '0' - Use pairs of the base_9_chars of the number_string to create a base_81_char. This should: - Work. - Be easy to programm. - Be fast, at least compared with the '76-solution'. > Sincerely, > > Gene Wirchenko > Sincerely, wolfgang -- wzwz.de/mail
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@telus.net> |
|---|---|
| Date | 2015-07-07 15:21 -0700 |
| Message-ID | <hljopatbidfbl6ianv5atd2sjs5dqnbd1j@4ax.com> |
| In reply to | #28340 |
On Tue, 07 Jul 2015 23:46:03 +0200, wolfgang zeidler
<invalid@invalid.invalid> wrote:
>Gene Wirchenko wrote:
>> On Tue, 07 Jul 2015 20:02:03 +0200, wolfgang zeidler
>> <invalid@invalid.invalid> wrote:
[snip]
>>> Why of all things 76?
>>>
>>> It shout be much easier if you would use a square number like 81 or 100
>>> as base.
>>
>> Why would that make it easier? Does 10 (a non-square) cause
>> problems?
>No, 10 causes no problem ( we talk about JavaScript ).
>JavaScript offers the opportunity to transform numbers to number_strings
>of base 2 to 36.
>Maybe/Likely 2, 4, 8, 16, 32 are faster than other bases, but I think
>that's not what we talking about.
>
>Causes base 76 any problem?
>That depends on how we define a 'problem'.
>76 is outside the range of 2..36.
>
>Naturally I can write a programm which generates a base_76_string, but
>that's a lot of work.
Not really. Repeated modulo. Basic p-code:
base=76 // or whatever
digitstring="0123456789ABCetc."
numberstring=""
while n>0
digit=n%base
lookup digit in digitstring table to get digitchar
numberstring=digitchar+numberstring
n/=base
return numberstring
This code will not handle negatives, but that is only a little more
complication.
>And this programm will surely be slow, it has to do a lot of calculations.
>It works, I wouldn't call it a "problem", but I will call it unnecessary
>difficult.
Does my code look as if it has a lot of calculations?
>The alternative:
>It's very easy to transform and re-transform a base_n_string to a
>base_m_string if m = n^k, n > 1, k > 0.
Using the names just previous, your previous statement was just
if m were a square of n, rather than n being the base being converted
from. That makes a big difference. (Converting to base 81 instead of
76 would not be any easier if n were 7, say.)
[snip]
Sincerely,
Gene Wirchenko
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | comp.lang.javascript
csiph-web