Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 05, 2016, 07:29:19 19:29


Login with username, password and session length


Pages: [1]
Print
Author Topic: help about picbasic  (Read 2417 times)
0 Members and 1 Guest are viewing this topic.
mohsen
Guest
« on: April 05, 2008, 09:02:56 09:02 »

hi
how I can work with numbers thet is bigger then one word (65536) in pic basic
 Undecided
Logged
mississippi1
Newbie
*
Offline Offline

Posts: 27

Thank You
-Given: 24
-Receive: 7


« Reply #1 on: April 06, 2008, 11:04:50 11:04 »

Than take 2 words, and if you cross boundary of the first word than add 1 to the second word.
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #2 on: April 06, 2008, 01:24:10 13:24 »

hi
how I can work with numbers thet is bigger then one word (65536) in pic basic
 Undecided
just use float
Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
TomJackson69
V.I.P
Active Member
*****
Offline Offline

Posts: 221

Thank You
-Given: 23
-Receive: 63


« Reply #3 on: April 16, 2008, 02:52:00 02:52 »

just use float


Hi Mohson,

Take your large decimal number and devide for 65536 ($FFFF), put the answer into HighWord, the remainder put in LowWord.

Ex)
       LargeNumber = float        / define variables
       HighWord      = word
       LowWord       = word

Now in your program do some calculation and get the data in the variable LargeNumber. Let say LargeNumber now = 987654.

Take     987654
            --------  = 15.07040405
            65536

Now put HighWord = 15
And       LowWord  = 4614    (.07040405 x 65536 = 4613.9999999)

Or you can convert your LargeNumber yo HEX number. 987654 =$F1206 (in Basic you must have Dec to Hex convert function.

Now HighWord = $0F = 15
And  LowWord  = $1206 = 4614  (HEX number is nicer)

Hope that help,

Tom

Sory I don't have PICbasic (know a little in Proton Basic)


       
Logged

Con Rong Chau Tien
Bitburner
Newbie
*
Offline Offline

Posts: 10

Thank You
-Given: 0
-Receive: 10


« Reply #4 on: April 16, 2008, 06:28:01 06:28 »

hi
how I can work with numbers thet is bigger then one word (65536) in pic basic
 Undecided

V2.50
With the latest versions of the PICBASIC PRO Compiler there is now a signed, long variable type. Each long variable is made up of 4 sequential bytes in memory - that’s 32 bits. The numeric values that can be represented in a long variable range from -2147483648 to 2147483647, or in some cases, from 0 to 4294967295.

For the non-long version of the compiler (PBPW.EXE), temporaries are word-sized. For the long version of the compiler (PBPL.EXE), temporaries need to be long sized.

Code:
Average Var Long
L1 = 123456 ‘ This is 123.456 in fixed point form
L2 = 234567 ‘ This is 234.567 in fixed point form
L3 = -456789 ‘ This is -456.789 in fixed point form
Average = (L1 + L2 + L3) / 3
Lcdout Sdec (Average / 1000), “.”, Dec3 ((Abs Average) // 1000))

There are some specific commands that can benefit from a larger variable size.
While all the commands can now accept longs as any of their parameters, longs can be helpful in commands such as Count, Pause, Pulsin, Pulsout, Rctime, Shiftin and Shiftout.
In the Count command, for example, a long variable can store a count far larger than the previous limit of 65535 using a word variable.
Shiftin and Shiftout can now move 32 bits with a single variable or constant.
Pauses can get really long, using longs.
Of course, loop commands like For..Next, Repeat..Until and While..Wend can also use a long variable.
Then there are the Lookdown2 and Lookup2 commands that can now search for and return very large numbers.


This should help you get over that 65535 barrier!

Have fun,
Bitburner
« Last Edit: April 16, 2008, 06:45:20 06:45 by Bitburner » Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC