Shop OBEX P1 Docs P2 Docs Learn Events
unsigned long in spin — Parallax Forums

unsigned long in spin

JkaneJkane Posts: 113
edited 2014-07-13 09:37 in Propeller 1
Hello,

I was curious on how to create an unsigned long variable in spin, 0 - 4294967296, I see that you can do it in pasm, but was looking for something in spin.
CON
  _clkmode   = xtal1 + pll16x                           
  _xinfreq   = 5_000_000                                'Set to standard clock mode and frequency (80 MHz)
  

VAR
  long  a_signed_long                                         a signed long -2147483647 -> 2147483648
 unsigned_long a_unsigned_long                      '0 -> 4294967296
  byte  a_byte
 word a _word 


[SIZE=3]
PUB Main

repeat unsigned_long  from 0 to 4294967296

  prt.dec(unsiged_long
 

[/SIZE]       


regards

Jeff

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-07-13 09:37
    All longs in Spin are treated as being signed. However, some operations (e.g. add subtract, booleans) work the same for signed and unsigned numbers, and you can use them with impunity. Other operations (e.g. multiply, compares) do not. You can get around some of the limitations by using the umath object in the OBEX.

    -Phil
Sign In or Register to comment.