Shop OBEX P1 Docs P2 Docs Learn Events
Floating point to integer? — Parallax Forums

Floating point to integer?

Sniper KingSniper King Posts: 221
edited 2008-06-12 17:11 in Propeller 1
I figured out string to float, float to string, now how about float to integer.· Thought that would be an easy one but of course learning russian.... i mean spin·has been a curve for sure.· Love it though.

What I am really trying to do is the opposite of the Float32Full method of FFloat.

[noparse][[/noparse]code]

Var

··· byte X

··· long Y

OBJ

······ Fp· :· "Float32Full"

Pub Change

X:=5

fp.start

y:=Fp.ffloat(x)



X:=??????(y)

[noparse][[/noparse]/code]





▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Was it pin 11 or 26?· Hmmm....··I think the smell of smoke tells the whole story.· Must be 26.



Michael King
Application Engineer
R&D
Digital Technology Group

Post Edited (Sniper King) : 6/11/2008 7:38:42 PM GMT

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-06-11 19:39
    The code is already in your posession, all you have to do is exclude the code in float to string which adds the decimal point and the fractional digits.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2008-06-11 22:24
    If you don't mind losing the fractional part:
    integer := FP.FTrunc(fpnumber) or integer := FP.FRound(fpnumber)
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-06-12 17:11
    Sorry I misread what you want, I thought you wanted a ASCII represented integer, John has provided the information you need.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.