By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,744 Members | 1,835 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,744 IT Pros & Developers. It's quick & easy.

converting numbers

P: n/a
Hi

I am using the base_convert() function to convert numbers between binary,
hexadecimal, decimal, etc... It works great, but I have problems converting
numbers with .'s

Like this number:

15.20 decimal will be 1111 as binary...

is there any way to include the rest of the number in the convertion?
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Sverre Bakke" <sv*****************@ingen-spam.online.no> wrote
in message news:<bn**********@dolly.uninett.no>...

I am using the base_convert() function to convert numbers between binary,
hexadecimal, decimal, etc... It works great, but I have problems converting
numbers with .'s

Like this number:

15.20 decimal will be 1111 as binary...

is there any way to include the rest of the number in the convertion?


Sure, just write your own conversion function. Note, however, that
you won't be able to use those binary, octal, or hexadecimal floats
anywhere; PHP only recognizes binary, octal, and hexadecimal integers.

Cheers,
NC
Jul 17 '05 #2

P: n/a
I don't think base_convert caters for floating point binary numbers,
which is a little silly, so you'll have a to write a function to do that
for you. I suggest you type cast it to a string, use the dot to divide
the string into two, and then convert each number into binary, and then
do some floating point arithmetic to get the true result. If somebody
would like to post such a function?

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.