Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: hexadecimal problem


Message #1 by "Rajat Singhal, Gurgaon" <rajat@g...> on Mon, 27 Nov 2000 13:01:14 +0530
hi ,

   I have  a problem . 

   I accept  a no. from user who has an option to either enter a 

decimal no. or a hexadecimal no. I also give him the priviledge to enter a

wildcard . 

Now if the user enters a decimal no . with a wild card like 4*00 then  i

send a query

to the database using the 'like' statement to search for values e.g. like

'4%00'

but the problem comes when the user enters a hexadecimal no. with a wildcard

.



     In this case , how do i send the query to the database ?



Thanks,

rajat





Message #2 by "Gregg Stults" <gstults@n...> on Mon, 27 Nov 2000 09:22:56 -0800
Wow, cool problem, :)



I'll take a stab at it....



I assume that the data in the database is stored in decimal format, so you

always have to convert your Hex number to decimal.



In the case of a Hex number with a wildcard, there would not be a one to one

conversion from Hex to decimal.



Here is my train of logic, please feel free to correct me if I am wrong...



If you allow a single wildcard position in a decimal number, you are, in

essence, allowing 10 different numbers to be represented.  This can be

thought of as simply replacing the wildcard with every possible number, 0

through 9, for a total of 10 possibilities.



If you allow a single wildcard position in a Hexadecimal number, you are, in

essence, allowing 16 different numbers to be represented.  Replacing the

wilcard with 0 through F for a total of 16.



One possible solution would be to write a function that converts the Hex

number with a wilcard to an array of 16 decimal numbers.  You could then

submit 16 queries or use a function like 'IN()' or 'LIST(), if available.

I'm sure there is some elegant way of doing it.



If you are allowing multiple wildcards then, well, you have a bigger

problem.  In that case, you might have to do something like write a function

that creates a temporary table with all the possible decimal numbers, then

join that table to your original table.



That's my stab...



Good luck,



Gregg





----- Original Message -----

From: Rajat Singhal, Gurgaon <rajat@g...>

To: ASP+ <aspx@p...>

Sent: Sunday, November 26, 2000 11:31 PM

Subject: [aspx] hexadecimal problem





> hi ,

>    I have  a problem .

>    I accept  a no. from user who has an option to either enter a

> decimal no. or a hexadecimal no. I also give him the priviledge to enter a

> wildcard .

> Now if the user enters a decimal no . with a wild card like 4*00 then  i

> send a query

> to the database using the 'like' statement to search for values e.g. like

> '4%00'

> but the problem comes when the user enters a hexadecimal no. with a

wildcard

> .

>

>      In this case , how do i send the query to the database ?

>

> Thanks,

> rajat

>

>

>


  Return to Index