Division with some decimal


Results 1 to 16 of 16

Threaded View

  1. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darklakebridge7 View Post
    Hi to everybody! I would have the necessity to perform the following division in PIC Basic, but I don't know from how stings to depart.
    A = B / 5,58 B is a constant
    I would have the necessity to visualize the result on a display LCD also visualizing 2 decimal. Can someone help me? Thanks everybody
    You do know that PBP does NOT deal with fractions and decimals...right?

    a var word
    b var word
    'start with a number in b
    1 - b = 655 ' maximum value in b is 655, otherwise word variable b will overflow
    2 - b = b * 100 'shift the decimal point over to right 2 places temporarily
    3 - a = b / 558 'constant value of 5.58 also has it's decimal point shifted over by 2 places

    1 - b = 655 (given)
    2 - b = 65500 (closest you can get without overflowing a word value)
    3 - a = 117 ( 65500 / 558, PBP doesn't do fractions)

    Do a search on 'decimal' and 'fraction' here and you'll find some stuff. Otherwise, download the floating point math routines from microchip if you need good accuracy.
    Last edited by skimask; - 7th May 2007 at 20:31.

Similar Threads

  1. variable + decimal
    By savnik in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 18th August 2009, 14:21
  2. Binary Coded Decimal
    By -Dan- in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 25th May 2009, 09:23
  3. 16bit variable and degrees conversion
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd May 2005, 17:27
  4. Decimal to binary conversion
    By Demon in forum Code Examples
    Replies: 9
    Last Post: - 25th February 2005, 20:05
  5. Convert a word variable to decimal
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th December 2004, 20:02

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