Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28005 > unrolled thread
| Started by | jonas.thornvall@gmail.com |
|---|---|
| First post | 2015-06-06 15:11 -0700 |
| Last post | 2015-06-07 02:40 +0200 |
| Articles | 10 — 3 participants |
Back to article view | Back to comp.lang.javascript
Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 15:11 -0700
Re: Make own type (object) type in javascript. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-07 00:57 +0100
Re: Make own type (object) type in javascript. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-07 01:33 +0100
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 17:37 -0700
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 17:50 -0700
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 18:03 -0700
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-06 18:07 -0700
Re: Make own type (object) type in javascript. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-06-07 10:19 +0100
Re: Make own type (object) type in javascript. jonas.thornvall@gmail.com - 2015-06-07 04:09 -0700
Re: Make own type (object) type in javascript. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-07 02:40 +0200
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-06-06 15:11 -0700 |
| Subject | Make own type (object) type in javascript. |
| Message-ID | <66362d49-af1e-400b-b026-0e6d9b679f98@googlegroups.com> |
Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit that still can be treated as a numerical value that can be added and subtracted, without bit operations? And if so can that type be stored within an array. I am interested in make type dependent upon base used. So if base 256 would create an 8 bit type, allocated and used in array. 128 an 7 bit type and so on. Is it possible?
[toc] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-06-07 00:57 +0100 |
| Message-ID | <87iob0l79e.fsf@bsb.me.uk> |
| In reply to | #28005 |
jonas.thornvall@gmail.com writes: > Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit > that still can be treated as a numerical value that can be added and > subtracted, without bit operations? No. <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-06-07 01:33 +0100 |
| Message-ID | <877frgl5lz.fsf@bsb.me.uk> |
| In reply to | #28007 |
ram@zedat.fu-berlin.de (Stefan Ram) writes: > Ben Bacarisse <ben.usenet@bsb.me.uk> writes: >>jonas.thornvall@gmail.com writes: >>>Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit >>>that still can be treated as a numerical value that can be added and >>>subtracted, without bit operations? >>No. > > An attempt at implementing an object »holding« 8 bit: It seems unlikely that he meant can one store small whole numbers in 64-bit floating point variables. He's been doing that for months (years?). <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-06-06 17:37 -0700 |
| Message-ID | <8deb0189-2aa7-409d-9ed4-f6a89f2cf56d@googlegroups.com> |
| In reply to | #28009 |
Den söndag 7 juni 2015 kl. 02:33:32 UTC+2 skrev Ben Bacarisse: > ram@zedat.fu-berlin.de (Stefan Ram) writes: > > > Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > >>jonas.thornvall@gmail.com writes: > >>>Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit > >>>that still can be treated as a numerical value that can be added and > >>>subtracted, without bit operations? > >>No. > > > > An attempt at implementing an object »holding« 8 bit: > > It seems unlikely that he meant can one store small whole numbers in > 64-bit floating point variables. He's been doing that for months > (years?). > > <snip> > -- > Ben. You are correct Ben, i want a type holding just X bits depending upon the chosen base.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-06-06 17:50 -0700 |
| Message-ID | <fc57b9d2-b804-4679-9a16-6457fb0f4970@googlegroups.com> |
| In reply to | #28009 |
Den söndag 7 juni 2015 kl. 02:33:32 UTC+2 skrev Ben Bacarisse: > ram@zedat.fu-berlin.de (Stefan Ram) writes: > > > Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > >>jonas.thornvall@gmail.com writes: > >>>Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit > >>>that still can be treated as a numerical value that can be added and > >>>subtracted, without bit operations? > >>No. > > > > An attempt at implementing an object »holding« 8 bit: > > It seems unlikely that he meant can one store small whole numbers in > 64-bit floating point variables. He's been doing that for months > (years?). > > <snip> > -- > Ben. But what is this Ben? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures Typed Arrays are new to JavaScript with ECMAScript Edition 6 and present an array-like view of an underlying binary data buffer. The following table helps you to find the equivalent C data types: TypedArray objects Type Size Description Web IDL type Equivalent C type Int8Array 1 8-bit twos complement signed integer byte int8_t Uint8Array 1 8-bit unsigned integer octet uint8_t Uint8ClampedArray 1 8-bit unsigned integer (clamped) octet uint8_t Int16Array 2 16-bit twos complement signed integer short int16_t Uint16Array 2 16-bit unsigned integer unsigned short uint16_t Int32Array 4 32-bit twos complement signed integer long int32_t Uint32Array 4 32-bit unsigned integer unsigned long uint32_t Float32Array 4 32-bit IEEE floating point number unrestricted float float Float64Array 8 64-bit IEEE floating point number unrestricted double double
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-06-06 18:03 -0700 |
| Message-ID | <4f18d56f-4f0e-44a2-ad96-a44f216e0e53@googlegroups.com> |
| In reply to | #28013 |
Den söndag 7 juni 2015 kl. 02:50:36 UTC+2 skrev jonas.t...@gmail.com: > Den söndag 7 juni 2015 kl. 02:33:32 UTC+2 skrev Ben Bacarisse: > > ram@zedat.fu-berlin.de (Stefan Ram) writes: > > > > > Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > > >>jonas.thornvall@gmail.com writes: > > >>>Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit > > >>>that still can be treated as a numerical value that can be added and > > >>>subtracted, without bit operations? > > >>No. > > > > > > An attempt at implementing an object »holding« 8 bit: > > > > It seems unlikely that he meant can one store small whole numbers in > > 64-bit floating point variables. He's been doing that for months > > (years?). > > > > <snip> > > -- > > Ben. > > But what is this Ben? > > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures > > Typed Arrays are new to JavaScript with ECMAScript Edition 6 and present an array-like view of an underlying binary data buffer. The following table helps you to find the equivalent C data types: > > TypedArray objects > Type Size Description Web IDL type Equivalent C type > Int8Array 1 8-bit twos complement signed integer byte int8_t > Uint8Array 1 8-bit unsigned integer octet uint8_t > Uint8ClampedArray 1 8-bit unsigned integer (clamped) octet uint8_t > Int16Array 2 16-bit twos complement signed integer short int16_t > Uint16Array 2 16-bit unsigned integer unsigned short uint16_t > Int32Array 4 32-bit twos complement signed integer long int32_t > Uint32Array 4 32-bit unsigned integer unsigned long uint32_t > Float32Array 4 32-bit IEEE floating point number unrestricted float float > Float64Array 8 64-bit IEEE floating point number unrestricted double double Is it not possible to make ones own view of the array data buffer, must one use the ones above?
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-06-06 18:07 -0700 |
| Message-ID | <c5a3dc77-5498-403d-88b2-f51f4fd07f42@googlegroups.com> |
| In reply to | #28014 |
Den söndag 7 juni 2015 kl. 03:03:24 UTC+2 skrev jonas.t...@gmail.com: > Den söndag 7 juni 2015 kl. 02:50:36 UTC+2 skrev jonas.t...@gmail.com: > > Den söndag 7 juni 2015 kl. 02:33:32 UTC+2 skrev Ben Bacarisse: > > > ram@zedat.fu-berlin.de (Stefan Ram) writes: > > > > > > > Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > > > >>jonas.thornvall@gmail.com writes: > > > >>>Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit > > > >>>that still can be treated as a numerical value that can be added and > > > >>>subtracted, without bit operations? > > > >>No. > > > > > > > > An attempt at implementing an object »holding« 8 bit: > > > > > > It seems unlikely that he meant can one store small whole numbers in > > > 64-bit floating point variables. He's been doing that for months > > > (years?). > > > > > > <snip> > > > -- > > > Ben. > > > > But what is this Ben? > > > > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures > > > > Typed Arrays are new to JavaScript with ECMAScript Edition 6 and present an array-like view of an underlying binary data buffer. The following table helps you to find the equivalent C data types: > > > > TypedArray objects > > Type Size Description Web IDL type Equivalent C type > > Int8Array 1 8-bit twos complement signed integer byte int8_t > > Uint8Array 1 8-bit unsigned integer octet uint8_t > > Uint8ClampedArray 1 8-bit unsigned integer (clamped) octet uint8_t > > Int16Array 2 16-bit twos complement signed integer short int16_t > > Uint16Array 2 16-bit unsigned integer unsigned short uint16_t > > Int32Array 4 32-bit twos complement signed integer long int32_t > > Uint32Array 4 32-bit unsigned integer unsigned long uint32_t > > Float32Array 4 32-bit IEEE floating point number unrestricted float float > > Float64Array 8 64-bit IEEE floating point number unrestricted double double > > Is it not possible to make ones own view of the array data buffer, must one use the ones above? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-06-07 10:19 +0100 |
| Message-ID | <87sia3kh94.fsf@bsb.me.uk> |
| In reply to | #28013 |
jonas.thornvall@gmail.com writes: > Den söndag 7 juni 2015 kl. 02:33:32 UTC+2 skrev Ben Bacarisse: >> ram@zedat.fu-berlin.de (Stefan Ram) writes: >> >> > Ben Bacarisse <ben.usenet@bsb.me.uk> writes: >> >>jonas.thornvall@gmail.com writes: >> >>>Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit >> >>>that still can be treated as a numerical value that can be added and >> >>>subtracted, without bit operations? >> >>No. >> > >> > An attempt at implementing an object »holding« 8 bit: >> >> It seems unlikely that he meant can one store small whole numbers in >> 64-bit floating point variables. He's been doing that for months >> (years?). >> >> <snip> >> -- >> Ben. > > But what is this Ben? > > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures Can you rely on Edition 6? I may have misunderstood your goal which I took to be a request for minimal sized objects. If you don't mind wasting bits, there are lots of ways to do what you ask (see other replies prompted by my "no" reply for some examples). But these new types only give you another kind of container into which to pack the data -- they don't allow you to do anything you could not do otherwise. <snip> -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | jonas.thornvall@gmail.com |
|---|---|
| Date | 2015-06-07 04:09 -0700 |
| Message-ID | <b9ef7fd1-b1f1-4c1a-a7e6-b3a2601eff3b@googlegroups.com> |
| In reply to | #28020 |
Den söndag 7 juni 2015 kl. 11:19:39 UTC+2 skrev Ben Bacarisse: > jonas.thornvall@gmail.com writes: > > > Den söndag 7 juni 2015 kl. 02:33:32 UTC+2 skrev Ben Bacarisse: > >> ram@zedat.fu-berlin.de (Stefan Ram) writes: > >> > >> > Ben Bacarisse <ben.usenet@bsb.me.uk> writes: > >> >>jonas.thornvall@gmail.com writes: > >> >>>Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit > >> >>>that still can be treated as a numerical value that can be added and > >> >>>subtracted, without bit operations? > >> >>No. > >> > > >> > An attempt at implementing an object »holding« 8 bit: > >> > >> It seems unlikely that he meant can one store small whole numbers in > >> 64-bit floating point variables. He's been doing that for months > >> (years?). > >> > >> <snip> > >> -- > >> Ben. > > > > But what is this Ben? > > > > https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures > > Can you rely on Edition 6? I may have misunderstood your goal which I > took to be a request for minimal sized objects. If you don't mind > wasting bits, there are lots of ways to do what you ask (see other > replies prompted by my "no" reply for some examples). But these new > types only give you another kind of container into which to pack the > data -- they don't allow you to do anything you could not do otherwise. > > <snip> > -- > Ben. Well the best would of course be to allocate a byte space and tell how to read it out tuples of 1,2 or 3 and so on using an index doing the multiples finding the correct index. And i can not see why programming languages do not allow this since it see so easy to implement, in a language like C. But i do not really understand hardware related stuff and reasons, for limitations upon implementations.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2015-06-07 02:40 +0200 |
| Message-ID | <2283260.pclIp03G5q@PointedEars.de> |
| In reply to | #28007 |
Ben Bacarisse wrote:
> jonas.thornvall@gmail.com writes:
>> Is it possible to create an object holding holding 1 bit, 2 bit, 3 bit
>> that still can be treated as a numerical value that can be added and
>> subtracted, without bit operations?
>
> No.
var o = {
valueOf: function () {
return (+!!this.bit3) * 4 + (+!!this.bit2) * 2 + (+!!this.bit1);
}
};
o.bit2 = 23;
/* 42 */
40 + o
/* 23 */
25 - o
--
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] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web