The Godfather talking
This is god damn my place! Capisci?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 27, 2024, 02:27:48 02:27


Login with username, password and session length


Pages: [1]
Print
Author Topic: help about picbasic  (Read 5454 times)
0 Members and 1 Guest are viewing this topic.
mohsen
Guest
« on: April 05, 2008, 08:02:56 08: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: 26
-Receive: 7


« Reply #1 on: April 06, 2008, 10:04:50 10: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: 4668

Thank You
-Given: 834
-Receive: 4322


There is no evidence that I muted SoNsIvRi


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

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

Note: I stoped Muteing bad members OK I now put thier account in sleep mode
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #3 on: April 16, 2008, 01:52:00 01: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, 05:28:01 05: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, 05:45:20 05: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