hi
how I can work with numbers thet is bigger then one word (65536) in pic basic
V2.50With 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.
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