# how to know the input value of integer

• 11-18-2009, 08:22 PM
ran830421
how to know the input value of integer
i am ran
my query is how to know the input value of integer is decimal or hexdecimal
• 11-18-2009, 08:27 PM
r035198x
Input from where?
• 11-18-2009, 08:33 PM
ran830421
i will explain
for ex consider integer variables a,b
a='0x5a';
b=90;
here both are displays same values when print them
i want know the input of a is decimal or hexdecimal. input value is given by others it will not displays to the programer
• 11-18-2009, 08:40 PM
r035198x
With those quotes it won't compile at all.
• 11-18-2009, 08:47 PM
mrmatt1111
Both values get stored in the same form (4 bytes for integer; base 16) and represented as an integer when you display it on the screen or in your code (not a decimal number!).

Code:

```int a = 0xF3; int b = 243; System.out.println(a); if(a == b)   System.out.println("Equivalant!"); if(0x000000F3 == 243)   System.out.println("Equivalant!");```
• 11-18-2009, 08:50 PM
ran830421
my problem is that input is given by other programmer it is decimal or hexdecimal value .
i want to know that the given input value is decimal or hexdecimal. based on this i can solve the puzzle.
for ex he gives the input for integer variable is 0x5a it is hexdecimal value then i will divide it by rgb format and solve the puzzle.
if it is decimal it will be solved by another way
• 11-18-2009, 08:56 PM
mrmatt1111
as r035198x asked "Input from where?"

If you input is the form of a string you can do something like this:

Code:

```int value = 0; try {   value = Integer.parseInt(input); //input is a string } catch(Exception e) {   System.out.println("Not an Integer") }```
• 11-18-2009, 09:11 PM
ran830421
i will explain clearly

package test.blurimg;

public class BlurImage {

public image blur_image(image i, int radius) {

return null;
}
// You could use this sample code to test your functions
// Following main fucntion contains 3 representative test cases
public static void main(String[] args) {
//TestCase 1
try {
image i = new image();
i.rows = 5;
i.columns = 3;
i.data = new int[][]{{6, 12, 18}, {5, 11, 17}, {4, 10, 16}, {3, 9, 15}, {2, 8, 14}};

BlurImage obj = new BlurImage();
image res = obj.blur_image(i, 2);
System.out.println("TestCase 1");
if (res != null) {
for (int k = 0; k < i.rows; k++) {
System.out.println();
for (int j = 0; j < i.columns; j++) {
System.out.print(res.data[k][j] + ",");
}
}
} else
System.out.println("NULL");
}
catch (Exception e) {
e.printStackTrace();
}
//TestCase 2
try {
image i = new image();
i.rows = 3;
i.columns = 5;
i.data = new int[][]{{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038}};

BlurImage obj = new BlurImage();
image res = obj.blur_image(i, 1);
System.out.println("\nTestCase 2");
if (res != null) {
for (int k = 0; k < i.rows; k++) {
System.out.println();
for (int j = 0; j < i.columns; j++) {
System.out.print(res.data[k][j] + ",");
}
}
} else
System.out.println("NULL");
}
catch (Exception e) {
e.printStackTrace();
}
//TestCase 3
try {
image i = new image();
i.rows = 3;
i.columns = 5;
i.data = new int[][]{{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038}};

BlurImage obj = new BlurImage();
image res = obj.blur_image(i, 4);
System.out.println("\nTestCase 3");
if (res != null) {
for (int k = 0; k < i.rows; k++) {
System.out.println();
for (int j = 0; j < i.columns; j++) {
System.out.print(res.data[k][j] + ",");
}
}
} else
System.out.println("NULL");
}
catch (Exception e) {
e.printStackTrace();
}
}
}

this is my puzzle here i.data is input it contains both decimal and hexdecimal values
if i.data contains hexdecimal value it will converted into RGB format and solved.
otherwise i will solve by another way.
• 11-18-2009, 09:22 PM
mrmatt1111
You have to understand, whether you represent your value as a hexdecimal or an integer, it's real value is exactly the same. There is no way to know the difference because there is no difference.
• 11-18-2009, 09:28 PM
r035198x
Where is the array data coming from?
Do you read it from a file? Do you receive it as an object or perhaps strings passed as program arguments?
This is the question that we have been asking and you have not answered.
• 11-18-2009, 09:29 PM
ran830421
if array contains hexdecimal value then it will in the form of RGB now i will divide it R,G,B and find the avg of r,g,b of surrounded values for a value.
if it is decimal i will find the avg of surrounded values for a value.

here i need to find out if array contains hexdecimal it will follow first case other wise second case

the solution for this puzzle will suitable for all input values like decimal and hexdecimal
• 11-18-2009, 09:34 PM
ran830421
here data is array of integers. they cannot allow using of strings.
here we are using the given inputs only. i already posted them along with puzzle.

package test.blurimg;

public class image {
public int[][] data;
public int rows;
public int columns;
}
• 11-18-2009, 09:42 PM
xcallmejudasx
Convert your input to a string and check with the subString method if it contains an 'x' or any letters 'a-f'
• 11-18-2009, 09:43 PM
r035198x
Then integers are just integers.
The values are the same.
This has already been said before but you continue to ignore it.
• 11-18-2009, 09:50 PM
ran830421
in my puzzle i am passing the object to a function . object contains array of integers .
once when i assign a hexdecimal value to integer it will convert into binary format.
when i was trying to convert it into string it will gives a decimal value even if we are assign the hexdecimal values. "we cannot change the inputs. it is rule for this contest"
• 11-18-2009, 10:01 PM
r035198x