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
  •  | 
  •  

Frage

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

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

War es hilfreich?

Lösung 2

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top