Shop OBEX P1 Docs P2 Docs Learn Events
Chapter 3, Excercise 12 — Parallax Forums

Chapter 3, Excercise 12

parskoparsko Posts: 501
edited 2006-07-15 21:32 in Propeller 1
When I compile it gives me an error message "expected an expression term" and it highlights the TRUNC command.

Any thoughts?

-Parsko

BTW- Video, USB2SER, Propstick, everyone is running happily!!! I love F10 so much!

{{ RealNumbers.spin}}
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

  iB =  760                                   'Integer constants
  iC = 3875
  iD = 1250
  
  B  =    7.6                                 'Floating-point constants
  C  =   38.75
  D  =   12.5
  
  K  =  100.0                                 'Real-to-Pseudo-Real multiplier

OBJ
  Term : "TV_Terminal"
  F    : "FloatMath"
  FS   : "FloatString"

PUB Math
  Term.Start(12)
  
  {Integer constants (real numbers * 100) to do fast integer math}
  Term.Str(string("Pseudo-Real Number Result: "))
  Term.Dec(iB*iC/iD)
  
  {Floating-point constants using FloatMath and FloatString objects}
  Term.Out(13)
  Term.Str(string("Floating-Point Number Result: "))
  Term.Str(FS.FloatToString(F.FDiv(F.FMul(B, C), D)))
  
  {Floating-point constants translated to pseudo-real for fast math}
  Term.Out(13)
  Term.Str(string("Another Pseudo-Real Number Result: "))
  Term.Dec(TRUNC(B*K)*trunc(C*K)/trunc(D*K))

Comments

  • NewzedNewzed Posts: 2,503
    edited 2006-07-13 23:22
    Parsko, put CONSTANT before TRUNC.

    sSid
  • NewzedNewzed Posts: 2,503
    edited 2006-07-13 23:35
    Parsko, I should hve been more specific.· Write it like this:

    ·term.dec(CONSTANT(TRUNC...............

    Sid
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-14 00:46
    This is a known problem with the "pre-release" Propellor Tool and has been corrected in the "release" version 1.0 due to be posted soon (the pre-release requires the "constant()" with·"trunc()" while the release version does not need it).
  • parskoparsko Posts: 501
    edited 2006-07-15 21:21
    Gotcha, I'll try it tomorrow when I'm in front of my prop. Will I need to remove the "constant(..." from the command when the new release comes out, or can I leave the code as is?

    -Parsko
  • Mike GreenMike Green Posts: 23,101
    edited 2006-07-15 21:32
    If you download and install the updated Propellor Tool (version 0.98), you won't need to change the tutorial examples, the corrections have already been made.
Sign In or Register to comment.