Sin and Cos Functions

PerthEng

Member
I have just been trying out the Sin and Cos functions in the PE simulator for the 28X1.
Code:
For b0 = 0 to 90
b1 = cos b0   ; replace cos with sin for other trig function
serout 7, N2400, (#b1)
NEXT b0
It all makes sense in term of the values being 100 time actual, so a result of 98 equates to 0.98.

But what I have noticed is that only every second degree provides a valid result.

b1 = sin 0
b1 = sin 2
b1 = sin 3. etc

all give valid results

but if the angle is an odd value the simulator returns a value of 0.

A search of the forum past posts and reading the manual did not spot anything suggesting only every second degree was accepted.

The manual mentions a 45 step look-up table, which I took to mean
for 0 -4 5 degrees = use the table value
and for 45 - 90 deg = something like SQR(1 - SIN(90-angle))


so the question is, is this a bug or intended
and, if a bug, is it in the simulator only and is working okay in the PICAXE chips for every one degree increment of angle.
 

hippy

Ex-Staff (retired)
This appears to be a simulator bug which we will fix. Possibly related to the 'division' issue.

Physical PICAXE should work as expected.
 
Top