BasicMicro - Forums

www.basicmicro.com
It is currently Sun May 20, 2012 11:21 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Negative Numbers
PostPosted: Thu Oct 29, 2009 3:52 pm 
Offline
Citizen

Joined: Sun Jul 05, 2009 12:01 pm
Posts: 12
Can anyone tell me why I get the output listed below from this code? I was expecting the = -1 to be true and 0 - 1 to be -1 .

code:
parenlevel var word
pause 2000
parenlevel = 0
serout s_out,i9600,[sdec parenlevel]
parenlevel = parenlevel - 1
if parenlevel = -1 then
serout s_out,i9600,["negative"]
endif
serout s_out,i9600,[13, sdec parenlevel]
end

Output:
0
65535

Setup:
Studio 1.0.0.14
Basic Atom 28 Rev d


Top
 Profile  
 
 Post subject: Re: Negative Numbers
PostPosted: Thu Oct 29, 2009 4:02 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Yep,

You have: parenlevel var word

SO parenlevel is an unsigned word. If you wish for it to show up as -1, you might try:
parenlevel var sword

Kurt


Top
 Profile  
 
 Post subject: Re: Negative Numbers
PostPosted: Fri Oct 30, 2009 5:53 am 
Offline
Citizen

Joined: Sun Jul 05, 2009 12:01 pm
Posts: 12
Thanks, that was it. I read studio doc and discovered sbyte and slong too.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO