Thread: Prolog inquiry

  1. #1
    Registered User
    Join Date
    Nov 2001

    Unhappy Prolog inquiry

    Hi all,
    Hopefully you all didn't mind if i ask some prolog question at here. Cos i finds that this board is the place that i can find the experience and best programmer from others site.

    Ya, important part.

    I have a difficulties in converting the the decimals number to hexadecimals and then convert it back. I know that we need to convert it first to binary rite and the nchange it to hex. But ont thing is i don have any clue on what command i need to use to convert it to binary and then convert it to hex. I have crack my head and still does not found any solutions.

    So, does anyone willing to help me pls. I am using the SWI-prolog 3.2.8

    Thanks first.

  2. #2
    Join Date
    Sep 2001
    And the Engrish of the day award goes to:
    > I have crack my head and still does not found any solutions.

    Seriously, if you're having trouble with it, post some code and im sure people will be able to point you in the right direction.
    The world is waiting. I must leave you now.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Hi there,
    Thanks for giving me the green light to ask for help.

    Currently i have think out an algorithm for the hexadecimals problem.
    Which is:

    -First i make a database like this for the helping to convert back the
    hexadecimals back to decimals value.

    -Then i put a function to read the input from the keyboard the
    hexadecimals values thats need to change to decimals.
    And then, i change the input to a list as below:

    -Using the mathematicals calculation, suppose the '2' should multiply
    with the '16 power of 1' and adding with the '0' multiply with the
    '16 power of 0'. And then adding together will comes out the value of
    '32' which is the decimals value.

    -What i have currently now are like this. I want to check with you
    and see if this algorithm works first before i start the coding part.

    Please advice. BTW, i have check some information from the web that
    there is a predicate for the swi-prolog '\x' which use for the
    hexadecimals value.
    I have try out the command like this:
    ?- writef('\x201').
    1 -----instead should having the value of 32.
    Does i using the wrong command. Please advice.
    Thanks and waiting for your reply. Good Day.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Prolog Compilers?
    By indigo0086 in forum Tech Board
    Replies: 0
    Last Post: 08-30-2007, 07:04 AM
  2. Should I learn C++ or Prolog?
    By coreyt1111 in forum C++ Programming
    Replies: 10
    Last Post: 11-14-2006, 09:35 AM
  3. Prolog
    By YankeePride13 in forum A Brief History of
    Replies: 5
    Last Post: 12-15-2005, 03:50 PM
  4. more prolog
    By bob20 in forum A Brief History of
    Replies: 12
    Last Post: 12-10-2002, 10:33 PM
  5. Prolog
    By bob20 in forum A Brief History of
    Replies: 6
    Last Post: 12-03-2002, 07:02 PM