Shop OBEX P1 Docs P2 Docs Learn Events
Pi, Apple Cherry? FP or Not or Both? — Parallax Forums

Pi, Apple Cherry? FP or Not or Both?

TJHJTJHJ Posts: 243
edited 2008-07-09 00:45 in Propeller 1
So Ive been sitting here trying to decide how this works and just decided it would be better to ask those who know more than me.

So Pi being a Floating point number.... (I thought last time I checked) Do I have to use it inside of a FP object?
So if I multiply 1000 * pi,like so
Var := 1000 * Pi



is the result 300 or 314? or neither, because its a Float number, and well float and non float just dont flow.
and it must be treated as

Var := f.Fmul(F.FFloat(1000),Pi)
Var := F.Fround(Var)





Does this yield 315 (3.145?? I think its been a while since Ive done pi by hand)

Or do I need to float convert pi as well before using it in a FP calculation?


I think all this relates to how is Pi stored as the constant, being as it is pre assigned in the rom, but which was is it stored.


Thanks all,
TJ

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-07-09 00:45
    The PI constant is floating point (standard IEEE format) so you need to use FMul to multiply it by another floating point number. If "F" is the floating point object, F.FRound(F.FMul(1000.0,PI)) would be 3142 (1000.0 x 3.1415926...)
Sign In or Register to comment.