1

Or 1 versus 1.0, or 2 versus 2.0...

Ideally, is there an operation that will behave differently on one than the other?

Chris Zhang
  • 968
  • 7
  • 16
  • Do you mean stored as text, or whether a number is an integer or a float/decimal? – Orbling Jun 27 '13 at 17:18
  • 1
    AFAIK, APL has three non-structural types, real, complex and text. Rather than integers and floats, etc. – Orbling Jun 27 '13 at 17:36
  • Whether a number is an integer or a float/decimal... It seems there isn't a way, if I simply type 3.0, the result is 3... so I'm guessing APL doesn't care if there is a '.0' component? – Chris Zhang Jun 27 '13 at 17:41
  • 1
    What I was saying is that it doesn't have an integer type per se. Just real and complex for numerics. So an integer is any numeric value `⍵` where `⍵=⌊⍵`. – Orbling Jun 27 '13 at 17:45
  • It also works for 1.0, which technically "has" a fractional part, no? – Chris Zhang Jun 27 '13 at 18:03
  • 1
    The fractional part of `1.0` is `.0` - which is usually defined to be no fractional part. All real and complex numbers have fractional parts, they are part of the integer class when that part is empty, 0. – Orbling Jun 27 '13 at 18:18
  • 1
    Well thank you immensely, good sir! – Chris Zhang Jun 27 '13 at 19:56
  • Hmmmm. As discussed, the answer is intrinsically, no; but there are idioms or algorithms that can test the fractional part of a number. Subject to Quad CT. Not sure if this is a supplementary question but I'm not sure what happens if a number with non zero fractional part is used for example as array index or as an axis. (this isn't so much about answering "is there a way to tell..." as asking the question Does it matter? – RFlack May 23 '14 at 03:43

2 Answers2

2

APL tries to insulate things like the actual storage type from the user. APL may or may not demote the type you've typed in, thus if you type 1.0 and expect double, you might really get boolean. This behaviour varies by implementation.

Be that as it may, some APL systems offer a function called []DR, for Data Representation. On my Dyalog APL v.10 system,

[]DR 3.0 is 83, one byte integer
[]DR 3   is 83, one byte integer
[]DR 1   is 83, one byte integer
[]DR 0   is 83, one byte integer
[]DR ~1  is 11, one bit boolean
[]DR 3.1 is 645, double floating point

Your mileage, and answers, will vary from system to system.

Lobachevsky
  • 1,222
  • 9
  • 17
0

No. There is no difference between 3 and 3.0 in APL.

Paul Mansour
  • 1,436
  • 9
  • 11