471,316 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

converting numbers

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
2 3019
"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
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.

Similar topics

2 posts views Thread by Mariusz Sakowski | last post: by
7 posts views Thread by Tor Aadnevik | last post: by
15 posts views Thread by jaks.maths | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.