# Thread: how to know the input value of integer

1. Member
Join Date
Nov 2009
Posts
7
Rep Power
0

## 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

2. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
10
Input from where?

3. Member
Join Date
Nov 2009
Posts
7
Rep Power
0

## 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

4. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
10
With those quotes it won't compile at all.
If you remove the quotes then hexadecimals start with 0x or 0X.

5. 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!).

Java 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!");```
Last edited by mrmatt1111; 11-18-2009 at 08:51 PM.

6. Member
Join Date
Nov 2009
Posts
7
Rep Power
0
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

7. as r035198x asked "Input from where?"

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

Java Code:
```int value = 0;
try
{
value = Integer.parseInt(input); //input is a string
}
catch(Exception e)
{
System.out.println("Not an Integer")
}```
Last edited by mrmatt1111; 11-18-2009 at 08:59 PM.

8. Member
Join Date
Nov 2009
Posts
7
Rep Power
0
i will explain clearly

package test.blurimg;

public class BlurImage {

public image blur_image(image i, int radius) {
//Write your code here

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.

9. 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.

10. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
10
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. Member
Join Date
Nov 2009
Posts
7
Rep Power
0
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

12. Member
Join Date
Nov 2009
Posts
7
Rep Power
0
here data is array of integers. they cannot allow using of strings.
we must follow the rules.
here we are using the given inputs only. i already posted them along with puzzle.

please refer them .

package test.blurimg;

public class image {
public int[][] data;
public int rows;
public int columns;
}

13. Convert your input to a string and check with the subString method if it contains an 'x' or any letters 'a-f'

14. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
10
Then integers are just integers.
The values are the same.
This has already been said before but you continue to ignore it.

15. Member
Join Date
Nov 2009
Posts
7
Rep Power
0
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"

16. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
10
Are we also allowed to read responses posted to this thread?

Why do you post at all if you ignore the responses that you get?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•