473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

unsigned int

I have mysql database for internal computer evidence and I store IP as
unsigned numeric value. It is very good for computing network ranges and
so on. But PHP do not support unsigned integer. So when I store values
to doatabase, I must convert it to string with sprintf. When reading it,
I get a string value with 10-digit number, bigger than maxint. I need to
convert it to signed int and work with it as a number (for making binary
arithmetics). I have discovered no way how to do it. Intval() or (int)
type conversion returns maxint. Converting it in mysql is anoying too,
because mysql cant do signed 32-bit int type conversion, only 64 bit.
Marek
Jan 30 '06 #1
3 14055
Marek Simon wrote:
I have mysql database for internal computer evidence and I store IP as
unsigned numeric value. It is very good for computing network ranges and
so on. But PHP do not support unsigned integer. So when I store values
to doatabase, I must convert it to string with sprintf. When reading it,
I get a string value with 10-digit number, bigger than maxint. I need to
convert it to signed int and work with it as a number (for making binary
arithmetics). I have discovered no way how to do it. Intval() or (int)
type conversion returns maxint. Converting it in mysql is anoying too,
because mysql cant do signed 32-bit int type conversion, only 64 bit.
Marek


I've just found something.
intVal(floatVal($num));

Marek

Jan 30 '06 #2
Marek Simon wrote:
I have mysql database for internal computer evidence and I store IP as
unsigned numeric value. It is very good for computing network ranges and
so on. But PHP do not support unsigned integer. So when I store values
to doatabase, I must convert it to string with sprintf. When reading it,
I get a string value with 10-digit number, bigger than maxint. I need to
convert it to signed int and work with it as a number (for making binary
arithmetics). I have discovered no way how to do it. Intval() or (int)
type conversion returns maxint. Converting it in mysql is anoying too,
because mysql cant do signed 32-bit int type conversion, only 64 bit.
Marek


Have you considered using the php/nmysql build-in functions (available
as of PHP 5.0):

PHP:
inet_ntop() http://nl2.php.net/manual/en/function.inet-ntop.php
inet_pton() http://nl2.php.net/manual/en/function.inet-pton.php

MySQL:
INET_ATON() and INET_NTOA()
http://dev.mysql.com/doc/refman/5.0/...functions.html

Jonathan
Jan 30 '06 #3
> Have you considered using the php/nmysql build-in functions (available
as of PHP 5.0):

PHP:
inet_ntop() http://nl2.php.net/manual/en/function.inet-ntop.php
inet_pton() http://nl2.php.net/manual/en/function.inet-pton.php

MySQL:
INET_ATON() and INET_NTOA()
http://dev.mysql.com/doc/refman/5.0/...functions.html

Jonathan


I do not have PHP 5.0 (only 4.3) but I will try that mysql functions. I
did those function on my own few days ago, a bunch of text parsing and
binary shifting, not usable for writing it into each query.
Marek
Jan 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: William Payne | last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set (with set I mean they equal one). I need to determine those bits and their position and create new numbers from them. For...
34
by: Andy | last post by:
Hi, Are 1 through 4 defined behaviors in C? unsigned short i; unsigned long li; /* 32-bit wide */ 1. i = 65535 + 3; 2. i = 1 - 3; 3. li = (unsigned long)0xFFFFFFFF + 3; 4. li = 1...
25
by: amit | last post by:
Hi, What will happen in following scenario.. long a = -2; longlong b = a long c; c = *(ulonglong *)&b; b = c; also when
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
20
by: Hanzac Chen | last post by:
Hi, I don't understand why this could happen? The Code 1 will output `fff9' and the Code 2 will output `1' How could the `mod 8' not have effect? /* Code 1 */ #include <stdio.h> #include...
4
by: techie | last post by:
I have defined a number of unsigned integer types as follows: typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; typedfe long long uint64; Is it...
10
by: =?iso-8859-2?B?SmFuIFJpbmdvuQ==?= | last post by:
Hello everybody, this is my first post to a newsgroup at all. I would like to get some feedback on one proposal I am thinking about: --- begin of proposal --- Proposal to add...
20
by: Junmin H. | last post by:
Hello, I am trying to print the range of unsigned char and unsigned int. The one for char is working good, gives me a correct output, however the other one for int doesnt, why?? Thanks #include...
6
by: Kislay | last post by:
Consider the following code snippet unsigned int i=10; int j= - 2; // minus 2 if(i>j) cout<<"i is greater"; else cout<<"j is greater"; Since i is unsigned , j is greater . I know why , but...
29
by: Kenzogio | last post by:
Hi, I have a struct "allmsg" and him member : unsigned char card_number; //16 allmsg.card_number
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.