Decimal to fraction conversion


Closed Thread
Results 1 to 21 of 21
  1. #1
    Join Date
    Dec 2006
    Posts
    38

    Default Decimal to fraction conversion

    I am looking for a way to convert a decimal number to a fraction I have looked thru the manual but cant seem to find a solution.

    What I need to do is convert say .0625 to 1/16

    I would like a resoultion of 1/16 of an inch.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tico View Post
    I am looking for a way to convert a decimal number to a fraction I have looked thru the manual but cant seem to find a solution.

    What I need to do is convert say .0625 to 1/16

    I would like a resoultion of 1/16 of an inch.
    Well,
    .0625 * 10000 = 625
    625 / 625 = 1
    1/16

    .1250 * 10000 = 1250
    1250 / 625 = 2
    2/16

    and so on and so on...

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    (results * 16)/1000 ???

    But we don't see and know what you're currently using... hard to guess
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    (results * 16)/1000 ???
    I'm waiting for the question 'how do I get a decimal point or a slash in the fraction' or something like that.

  5. #5
    Join Date
    Dec 2006
    Posts
    38


    Did you find this post helpful? Yes | No

    Talking

    Thanks for the reply mister_e
    I have not written anything yet I am just begining this code for some reson I thought there might be some function built in.
    Its okay I guess I will just have to do it the straight math way.
    Last edited by tico; - 26th April 2007 at 01:52.

  6. #6
    Join Date
    Dec 2006
    Posts
    38


    Did you find this post helpful? Yes | No

    Default What happened skimask

    Hey skimask
    WOW 3 minutes went by and you realized you didnt say anything cocky, or did you just have to think for a while due to the fact you couldnt tell me to refer to the little green book at section x.yy

    and as for your cocky comment you can continue to wait for the other shoe to drop.

    but just so you dont have something else cocky to come back with I guess this will work...............

    LCDOUT $fe, 1, #Product,"/",#Remainder

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tico View Post
    Hey skimask
    WOW 3 minutes went by and you realized you didnt say anything cocky, or did you just have to think for a while due to the fact you couldnt tell me to refer to the little green book at section x.yy
    and as for your cocky comment you can continue to wait for the other shoe to drop.
    but just so you dont have something else cocky to come back with I guess this will work...............
    LCDOUT $fe, 1, #Product,"/",#Remainder
    What's the fascination here?

    And as far as the 'I'm waiting for the question 'how do I get a decimal point or a slash in the fraction' or something like that.' comment...if you'll look closer, I don't remember seeing a name attached to that...unless I missed it.

    And sorry it took me 5 minutes to get that comment to you.
    I'll try to be quicker next time...mmmmkkk?!!?!

  8. #8
    Join Date
    Dec 2006
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    What's the fascination here?
    The fascination is that you realized I actually helped someone without being cocky about it

    And as far as the 'I'm waiting for the question 'how do I get a decimal point or a slash in the fraction' or something like that.' comment...if you'll look closer, I don't remember seeing a name attached to that...unless I missed it.
    fourth post down is your comment on mister_e 's post

    And sorry it took me 5 minutes to get that comment to you.
    I'll try to be quicker next time...mmmmkkk?!!?!
    actually it took you 3 minutes 09:17 first post 09:20 second post 20-17= 3

    unless I forgot 1st grade math

    I have been on this forum for a little while now and I always dread having to put up a post asking for help due to ridicule and snobby answers from people like yourself.

    I try to learn afterall I spent lots of money on PBP a development system and associted learning items, after searching and looking thru the manual, I dont always find the answers to me questions so I need to post to this forum and I always wait for someone like yourself to put a nasty post up like RTFM RTFD or whatever, sometimes your read but dont comprehend or get confused, hence the need for a question on this forum, afterall I thought that was the forums purpose to help others not ridicule your next victim as you so seem to enjoy post after post.

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    And sorry it took me 5 minutes to get that comment to you.
    I'll try to be quicker next time...mmmmkkk?!!?!
    Quote Originally Posted by tico View Post
    actually it took you 3 minutes 09:17 first post 09:20 second post 20-17= 3
    unless I forgot 1st grade math
    Hmmm....yep, forgot 1st grade math and reading.
    I still get 5 minutes for ME to get that comment to YOU.
    And again, I don't see any reference in post #4 that relates to you specifically. Do you?

  10. #10
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default True knowledge is knowing nothing at all

    I have to say that it makes me very upset when I read things that generally speaking put a person down because of something that they don't know. Part of the reason why some people - (including myself) - are afraid to ask questions is being in total fear of ridicule.

    Some students at the online UNI that I'm studying at post questions on the messages boards with their name reading anonymous. This is terrible.

    Unless you're a complete asshole - true knowledge is knowing nothing at all and not being a smart ass when you're able to help someone out with something. Besides, these people often fall flat on their ass when they're challenged by a true contender. Turns out that they actually know very little themselves. Pretending to be smart better put.

  11. #11
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    tico,

    (ignores all the hard feelings going back and fourth)

    As far as your original problem goes, how do you intend to hold a fractional number in memory? PBP only handles integers (sad but true).

    So you are limited to schemes such as working with your values scaled up by say 1,000, so 1/16 would be stored as 62 (1/16 * 1000 and truncated to an integer) and you can divide by 62 to see how many 1/16 pieces it has.

  12. #12
    Join Date
    Dec 2006
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ErnieM View Post
    tico,

    (ignores all the hard feelings going back and fourth)

    As far as your original problem goes, how do you intend to hold a fractional number in memory? PBP only handles integers (sad but true).

    So you are limited to schemes such as working with your values scaled up by say 1,000, so 1/16 would be stored as 62 (1/16 * 1000 and truncated to an integer) and you can divide by 62 to see how many 1/16 pieces it has.
    I thought that I could use the method described in post 2 or 3

    divide say 11.5 to get the following results
    5/16 Vector1
    15/16 Vector2
    1 11/16 Vector3
    2 5/8 Vector4
    3 15/16 Vector5
    5 3/4 Vector6Center
    7 9/16 Vector7
    8 7/8 Vector8
    9 13/16 Vector9
    10 9/16 Vector10
    11 3/16 Vector11

    I was hoping that this is possible to do with PBP, If I am wrong plese let me know. I am going to begin writing some code to do this tommorow.


    opps forgot the formula..... as in excel
    Round ((11.5/2) -((11.5/2)*(0.9)^0.5),3 = 5/16
    I am hoping that PBP can process this type of formula, if not its back to the drawing board
    Last edited by tico; - 26th April 2007 at 23:27. Reason: forgot formula

  13. #13
    Join Date
    Dec 2006
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Hmmm....yep, forgot 1st grade math and reading.
    I still get 5 minutes for ME to get that comment to YOU.
    And again, I don't see any reference in post #4 that relates to you specifically. Do you?
    Lets see 3 people involved in this thread at that time, Myself Mister_e and Skimask.

    I guess you werent talking to yourself, you claim it wasnt towards me so you must have been saying it to mister_e.

    but then again I am just a beginner at this, so maybe I have to refer to the little green book to get the right answer. I wonder what section that is under!

  14. #14
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tico View Post
    Round ((11.5/2) -((11.5/2)*(0.9)^0.5),3 = 5/16
    I am hoping that PBP can process this type of formula, if not its back to the drawing board
    PBP would have a heart attack with that.

  15. #15
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Yes and no, PBP have it's limit... it's not something new. But decent math approach would save the day.

    To make a short story, PBP works with integer, nowhere in the manual you'll find an answer about floating points and or square power.

    Thinking never killed... sure you use the easy route... but...

    i think few people may need to relax or simply be ban out of here...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  16. #16
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Post just a little bit of brain work ...

    Hi, Steve

    Why not change the formula to :

    16 x 115 / 4 x ( 200 - SQR ( 36 000 )) = 5 000 ( exactly 4721. .... ! PbP will return 5060 here ... )

    PbP would do that without any pain ... but not very precisely, as you see !!!

    Alain

    Ok, ... also just look for possible overflows !!!
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  17. #17
    Join Date
    Dec 2006
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Oh boy looks like I got over eager with another project, well I will see what I can do to get some sort of formula working in PBP.
    Looks like I will be doing alot of debug and lcdout on this one.

  18. #18
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tico View Post
    Oh boy looks like I got over eager with another project, well I will see what I can do to get some sort of formula working in PBP.
    Looks like I will be doing alot of debug and lcdout on this one.
    Don't forget about the floating point math routine package that Microchip has (and are at the MeLabs site). Those subroutines will handle the math that PBP won't...but you'll have to learn how to interface with them...

  19. #19
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,651


    Did you find this post helpful? Yes | No

    Smile just curious ...

    Hi, Tico

    I'm curious to see where your formula came out ... and what used for.

    looks too much like a triangle solving and inch converting !!!

    Alain

    PS ... see also here for math ... http://www.micromegacorp.com/pbp.html

    a V3 chip is also available ... don't hesitate to browse !!! http://www.micromegacorp.com/umfpu-v3.html
    Last edited by Acetronics2; - 27th April 2007 at 14:39.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  20. #20
    Join Date
    Dec 2006
    Posts
    38


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Tico

    I'm curious to see where your formula came out ... and what used for.

    looks too much like a triangle solving and inch converting !!!

    Alain

    PS ... see also here for math ... http://www.micromegacorp.com/pbp.html

    a V3 chip is also available ... don't hesitate to browse !!! http://www.micromegacorp.com/umfpu-v3.html
    The formula divides a circle into sections that have an equal area.

    Didnt have a chance to work on any code today got called out to the field.
    Will work on some possibly over the weekend if not I will on monday.

  21. #21
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's still the huge LOOKUP table + interpolation method, but, not sure that i saw the real maths here or if i'm just brainless today... or both
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 01:48
  2. Help for decimal conversion
    By eva in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th March 2007, 18:20
  3. microns to decimal conversion
    By Rleonard in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th February 2007, 14:37
  4. Decimal to Binary Conversion
    By schlaray in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd December 2006, 14:58
  5. Decimal to binary conversion
    By Demon in forum Code Examples
    Replies: 9
    Last Post: - 25th February 2005, 20:05

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