Re: help with storing a large binary number as bigint
Hi Byron, This should be a relatively simple question but after looking through the manual for a while I didn't see how to do it. I am working in php and need to store a large binary number in the database. When I try and convert it to a int in php its too big so it converts it to a float and I loose all all precision witch makes it worthless to me. Is there a way to let mysql do the conversion since the number I am working with is 48bits and bigint can store 63bits??? I would need to be able to insert and select it as a binary string? Yes, you can do this. Probably the best way to do this is to insert it as a hexadecimal number. Is the binary string in big or little endian form? If it's big endian, you can convert it directly to hex with bin2hex(), prefix it with 0x, and insert it as: INSERT INTO mytable (x, y, ...) VALUES (0x123456, 0x654321); If it's in little-endian format, you will need to do the byte-swapping before/after the bin2hex. (In pure PHP, it might be easier after.) Regards, Jeremy -- Jeremy Cole MySQL Geek, Yahoo! Inc. Desk: 408 349 5104 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: help with storing a large binary number as bigint
You could use the mysql CAST or CONVERT functions Byron.Albert wrote: Hey all, This should be a relatively simple question but after looking through the manual for a while I didn't see how to do it. I am working in php and need to store a large binary number in the database. When I try and convert it to a int in php its too big so it converts it to a float and I loose all all precision witch makes it worthless to me. Is there a way to let mysql do the conversion since the number I am working with is 48bits and bigint can store 63bits??? I would need to be able to insert and select it as a binary string? Thanks for any help. Byron Albert -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
help with storing a large binary number as bigint
Hey all, This should be a relatively simple question but after looking through the manual for a while I didn't see how to do it. I am working in php and need to store a large binary number in the database. When I try and convert it to a int in php its too big so it converts it to a float and I loose all all precision witch makes it worthless to me. Is there a way to let mysql do the conversion since the number I am working with is 48bits and bigint can store 63bits??? I would need to be able to insert and select it as a binary string? Thanks for any help. Byron Albert -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]