Using Floating Point to integer subroutines


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Feb 2009
    Location
    Southern California
    Posts
    86


    Did you find this post helpful? Yes | No

    Default Re: Using Flaoting Point to integer subroutines

    Thanks to you both, that was the information I needed. I went through the readme file and the FP1832L.bas file again and I still don't see where it says AARG starts at AARGB2, but you obviously know what your talking about because I have been able to make progress on my project now. Thanks again.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Using Flaoting Point to integer subroutines

    Hi,
    In this case I certainly won't take any credit because right now I don't understand it either. I'm looking at the README and at the FP1832L.BAS and I don't see it.
    I wonder if it's a byte order thing or something like that?

    /Henrik.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Using Flaoting Point to integer subroutines

    Well, having never used the Floating Point routines before ... you still knew the value went in AARG instead of Aint ... that's worth something.
    I guess it's easier when you know how it works.

    A floating point value consists of 4 bytes (32-bits).
    The highest byte is the exponent.

    Looking at the list of variables in FP1832L.bas, the only way to put 4 bytes in a row with the exponent lining up with AEXP is to start at AARGB2 ($1d).

    Code:
    aint    var     long $1c	' Long access to AARG
    AARGB3  var     aint.byte0	' $1c
    AARGB2  var     aint.byte1	' $1d
    AARGB1  var     aint.byte2	' $1e
    AARGB0  var     aint.byte3	' $1f
    AEXP    var     byte $20
    Microchip saves RAM space by using the same memory for Floats and Integers.
    But when you have an integer value, the LONG variable uses AARGB3-AARGB0 (aint).

    I believe the routines were intended to be used by starting with integers, converting to floats, and doing the math from there.
    They were never intended to accept previously encoded floating-point values, whether IEEE or Microchip format.
    Hence that ability is not documented.

    Undocumented features are way more fun than the documented ones.
    DT

Similar Threads

  1. Microchip 32bit floating point to integer conversion
    By timmers in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 1st February 2011, 17:49
  2. Getting out of floating point
    By jcb344 in forum General
    Replies: 3
    Last Post: - 5th August 2008, 22:18
  3. Replies: 5
    Last Post: - 28th May 2008, 11:20
  4. Floating Point
    By jrudd in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th May 2005, 15:19
  5. help floating Point!
    By Eric in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th December 2003, 22:18

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts