divide


Closed Thread
Results 1 to 7 of 7

Thread: divide

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: divide

    Simple answer:
    Because PBP uses integer math, you won't get any meaningful value from 1/x.

    You will need to think in terms of integers and scale your values appropriately.

    The other alternatives is to try the floating point routines found here: http://melabs.com/resources/fp.htm

  2. #2
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: divide

    First of all, use longs because you will need the bit space. Next decide your units that will result in an integer to display. For this example, lets choose ms. Since there are 1000 ms in a second, to get period as whole ms, instead of dividing 1 by x (Hz), divide 1000 by x(Hz) which is the same as (1/x)*1000.
    Obviously, if you want units of us then it's 1,000,000/x. You can see why longs are required.

Members who have read this thread : 0

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

Posting Permissions

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