
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 SWIprolog 3.2.8
Thanks first.

And the Engrish of the day award goes to:
> I have crack my head and still does not found any solutions.
*snickers* :D
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.

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.
hex(0,0).
hex(1,1).
hex(2,2).
hex(3,3).
hex(4,4).
hex(5,5).
hex(6,6).
hex(7,7).
hex(8,8).
hex(9,9).
hex(a,10).
hex(b,11).
hex(c,12).
hex(d,13).
hex(e,14).
hex(f,15).
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:
[2,0].
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 swiprolog '\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.
Yes
?
Does i using the wrong command. Please advice.
Thanks and waiting for your reply. Good Day.