For Programmers: Free Programming Magazines  


Home > Archive > APL > February 2006 > Re: DR









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: DR
Ibeam2000

2006-02-11, 7:55 am

Dyalog APL supports, at this time, at least three widths of integers.
Hopefully, when they release 64 bit integers, it will not impact the
existing widths.

In Dyalog, []DR -128 127 is 83
[]DR -32768 32767 is 163
[]DR -2147483648 2147483647 is 323

0 10 decode of the answer separates the last digit. Thus 323 means a
data type of 3, integer, at 32 bits per element. []DR of a 64 bit
integer would be 643.

Dyalog, seemingly, does a sort of demand-driven type demotion. Only if
you ask for the []DR of something does Dyalog actually compact it.
Space/time optimisation favours space.

APL*Plus/PC took the bold step, possibly for performance and storage
reasons, to introduce 2 byte integers instead of the customary 4, back
in the early 1980s. The later STSC Unix interpreters, which the
current APL+Win and SAX are based on, went back to 4 byte integers.

To my knowledge, APL+Win only has the 4 byte integers. I don't however
have the latest release.

Nested Arrays also have interesting differences between the systems.
In Dyalog, a mixed simple array looks no different than a nested array.
[]DR 'cat',42 []DR 'cat' 42 and []DR 'cat' 'fat' all return 326.
In APL+Win v3.6, []DR 'cat',42 returns 807, while []dr 'cat' 42 also
returns 807 (?!?), while []DR 'cat' 'fat' returns an expected 326. 326
would mean possibly like a 32 bit pointer of data type #6, nested
array, while 807 would mean an 80 bit element of data type #7, mixed.

One thing conspicuously missing from all APLs that I am aware of is a
short floating point format, i.e. []DR SHORT is 325.

IBM APL2 under Windows, at least my free trial edition, does not have a
[]DR. I haven't tried APLX yet.

The way I did this once in VSAPL to examine a variable was to first do
a []WA to force a garbage collection, then "overtake" the variable,
(i.e. 10000 take X), check []WA, delete it, then check []WA again. You
could then infer the type of the variable, then get the correct size.
The reason this was necessary was that you could do a pretty good APL
file system with one of the APs (it wasn't AP111, maybe AP123??) but
had to watch out for replacing a "component" which wasn't exactly the
same size as what was in the component before.

If you want to do actual bit-level type conversion with []DR, then you
need to understand the various floating point formats. There were some
very good functions supplied with VSAPL and APL2 which converted, in
APL, the IBM 360 floating point format to character. This would be
completely different for the PC stuff.

David Liebtag

2006-02-11, 7:55 am

The APL2 external function PFA returns a character vector that contains a
description of the right argument. APL2 supports 1 bit Booleans, 4 byte
integers, 8 byte floating point numbers, 16 byte complex floating point
number pairs, 1 byte characters, 4 byte characters, 8 byte integer
progression vectors, and general arrays. The external functions ATR and RTA
can be used to coerce data between different types including coercing types
of elements of general arrays.

User-written external functions have access to the internal representation
of arguments and can access their type which is a value of 0 through 7 for
the above types. It would be trivial to write an external function that
returned this type value as an integer.

David Liebtag
IBM APL Products adn Services


AA2e72E

2006-02-11, 6:55 pm

David,
How does APL2 convert values for writing to the Registry as REG_BINARY
and REG_DWORD?

David Liebtag

2006-02-11, 6:55 pm

APL2's tool for writing and reading application data to and from the
registry writes all data as binary. It writes the APL2 canonical format (a
slight variation of the internal form) to the registry. It is not really
intended to cooperate with other applications that need to access the same
registry data, although it is possible since the canonical form is a
documented format.

Users can also access the registry APIs directly and write the data however
they want.

David Liebtag
IBM APL Products and Services


AA2e72E

2006-02-11, 6:55 pm

I am getting somewhat . I have always understood binary to mean a
pattern of 1 and 0. However, REG_BINARY seems to be a series of values in
base 256 so 1278 is 4 254 (or, 4 FE in hex) i.e. (4x256*1)+254x256*0
Likewise, for REG_DWORD, (4/256) {encode} 1278 to produce the 4 bytes.
If I use this to write this in APL to write the registry and read the
values in VB, I get the same values back.

AA2e72E

2006-02-11, 6:55 pm

I got that wrong!

For REG_DWORD, (with APL+Win) I need 82 []dr 1278 rather than (4/256)
{encode} 1278.

The problem is that the result of 82 []dr 1278 relates to the []av of
APL+Win: the resulting string is different for APLX or APL/W.

David Liebtag

2006-02-11, 6:55 pm

In Microsoft registry terms, binary means arbitrary byte values.

Look here for more info:

http://msdn.microsoft.com/library/d...value_types.asp

David Liebtag


Eric Landau

2006-02-16, 6:55 pm

In article <1139655497.020690.185400@g44g2000cwa.googlegroups.com>,
"Ibeam2000" <Ibeam2000@gmail.com> wrote:

>To my knowledge, APL+Win only has the 4 byte integers. I don't however
>have the latest release.


APL+Win only works with 4-byte integers internally, but you can generate
2-byte integers with []DR.


Eric Landau, APL Solutions, Inc.
"Sacred cows make the tastiest hamburger." - Abbie Hoffman
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com