Data representation
6 posts
• Page 1 of 1
Data representation
I'd appreciate to understand the following different results (version 12.1):
and
- Code: Select all
⎕dr 1
83
⎕dr 1⍴1
83
⎕dr 2⍴1
11
and
- Code: Select all
⎕dr 1↑1 1
11
⎕dr 1↑2⍴1
83
⎕dr 1↑2⍴1 1
11
-
giangiquario - Posts: 46
- Joined: Thu Nov 26, 2009 8:55 am
- Location: Milano, Italia
Re: Data representation
Strange , in your second example, I get this :
.. as opposed to the '83' result that your example shows .
Classic Version: 12.1.1.6592
Created: Sep 28 2010 at 21:12:05
Build ID: 8c8ab56b
- Code: Select all
⎕dr 1↑2⍴1
11
.. as opposed to the '83' result that your example shows .
Classic Version: 12.1.1.6592
Created: Sep 28 2010 at 21:12:05
Build ID: 8c8ab56b
- PhilGray
- Posts: 50
- Joined: Sat Mar 13, 2010 7:55 pm
Re: Data representation
In 12.1.0
- Code: Select all
⎕dr 1
83
⎕dr 1⍴1
11
⎕dr 2⍴1
11
⎕dr 1↑1 1
11
⎕dr 1↑2⍴1
11
⎕dr 1↑2⍴1 1
11
- alexbalako
- Posts: 16
- Joined: Mon Nov 30, 2009 8:58 pm
Re: Data representation
My version is:
Classic Version: 12.1.1.5252
Created: May 5 2010 at 21:26:48
Build ID: ffa69d95
-
giangiquario - Posts: 46
- Joined: Thu Nov 26, 2009 8:55 am
- Location: Milano, Italia
Re: Data representation
⎕DR was introduced to Dyalog after many years. By this time, we had established the principle of representing numbers internally in the "most efficient" (in terms of space and time) form. In the classic APL language, a number is a number is a number ...
We found by experiment that maintaining the scalar literal values 0 and 1 as bytes, rather than as bits, made applications run slightly faster. These values occur very frequently and not having to mask out bits each time they were accessed gave us a small but measurable performance improvement.
This is what I expect to see:
We found by experiment that maintaining the scalar literal values 0 and 1 as bytes, rather than as bits, made applications run slightly faster. These values occur very frequently and not having to mask out bits each time they were accessed gave us a small but measurable performance improvement.
This is what I expect to see:
- Code: Select all
Dyalog APL/W Version 12.1.1
Serial No : 000000
Unicode Edition
DEBUG Build
Fri Jan 07 09:06:34 2011
clear ws
⎕dr 1
83
⎕dr 1⍴1
11
⎕dr 2⍴1
11
⎕dr 1↑1 1
11
⎕dr 1↑2⍴1
11
⎕dr 1↑2⍴1 1
11
- JohnS|Dyalog
Re: Data representation
I have looked more at why:
generally give 11 (1-bit boolean) but sometimes 83 (8-bit integer). That it is not 11 might suggest that the array doesn't contain just the values 0 and 1; that it can give two different values might also suggest a problem. Be assured that neither is the case; in both cases the array being examined is a length 1 vector containing the numeric value 1. The internal representation may indeed vary but that is only visible to you when you call ⎕dr; it is different because the best optimisation technique is sometimes a close call and subtle differences in the environment etc affect the choices the interpreter makes.
In a clear workspace you will see the following:
The first example can also give 83 depending on what else is in the workspace, which is what has happened in the reported case.
- Code: Select all
⎕dr 1⍴1
⎕dr 1↑2⍴1
generally give 11 (1-bit boolean) but sometimes 83 (8-bit integer). That it is not 11 might suggest that the array doesn't contain just the values 0 and 1; that it can give two different values might also suggest a problem. Be assured that neither is the case; in both cases the array being examined is a length 1 vector containing the numeric value 1. The internal representation may indeed vary but that is only visible to you when you call ⎕dr; it is different because the best optimisation technique is sometimes a close call and subtle differences in the environment etc affect the choices the interpreter makes.
In a clear workspace you will see the following:
- Code: Select all
⎕dr 1⍴1
11
⎕dr 1⍴2-1
83
The first example can also give 83 depending on what else is in the workspace, which is what has happened in the reported case.
-
Richard|Dyalog - Posts: 44
- Joined: Thu Oct 02, 2008 11:11 am
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group