Pascal Math |
|
Any questions send them to pascalmath@teentwo.8m.com This is one function that Turbo Pascal does not have and it can be quite useful to save you time. Function Power(number,top:integer) : real; So instead of writing a loop to times x with itself y times you can use this. Any questions send them to pascalmath@teentwo.8m.com 2. Sine and Cos functions in degrees The sin and cos function in pascal is in radians. A
complete rotations is 180 degrees but it is also 2*Pi radians. So to get sin and cos to
degress just divide by 180 / pi. Function Sine(num:word) : real; Function Cose(num:word); Any questions send them to pascalmath@teentwo.8m.com 3. Why are the same random numbers used each time I run my program Software random number generators apply a function to a RandSeed which cycles the seed through its possible values in a quasi-random way. Each call to the random number generator does one iteration of the function, and returns a result based on the new seed value. When your program loads, this seed will have some default value (probably 0). If you do not change the seed, a series of calls to the random number generator will yield the same series of "random" numbers every time your program is run. (Obviously, this will make it easier to track down the bugs!) Typically, the system clock is used to provide a value for the random number seed: Even if a given task is always run at the same time of day, a difference of a few milliseconds is enough to put a good random number generator in an entirely different part of its sequence. In Borland Pascal, the command to randomize the seed is (surprise!) Randomize; in Think Pascal for the Mac, the equivalent command is QwertyUiop. Note that you should only call this routine once per program, when it first loads, or at the very least at times separated by minutes or hours - calling it on every timer tick (say) will just reset the 'random' sequence several times a second! Any questions send them to pascalmath@teentwo.8m.com 4. How do I obtain high and low parts of a byte variable? function HIBYTEFN (x : byte) : byte; function LOBYTEFN (x : byte) : byte; Any questions send them to pascalmath@teentwo.8m.com |
|
This page is best viewed in 800x600x256. This page was last edited Tuesday, June 27, 2000 |