Title: help about picbasic Post by: mohsen 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 :-\ Title: Re: help about picbasic Post by: mississippi1 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.
Title: Re: help about picbasic Post by: pickit2 on April 06, 2008, 12:24:10 12:24 hi just use floathow I can work with numbers thet is bigger then one word (65536) in pic basic :-\ Title: Re: help about picbasic Post by: TomJackson69 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) Title: Re: help about picbasic Post by: Bitburner 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 :-\ 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 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 |