Is there any way to tell the difference between a number 3.0 and 3 in APL?

StackOverflow https://stackoverflow.com/questions/17349404

  •  01-06-2022
  •  | 
  •  

Question

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

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

Était-ce utile?

La solution 2

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

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top