import java.io.*;
class DecToHex
{
	public static void main(String[] args)
	{
		Console console=System.console();
		System.out.println("Please enter a decimal number");
		String input;
		input=console.readLine();
		int dec;
		dec=Integer.parseInt(input);
		String hex="";
		int remainder;

		String hexChars="0123456789abcdef";
		if(dec==0)
			hex="0";
		while(dec!=0)
		{
			remainder=dec%16;
			hex=hexChars.charAt(remainder)+hex;
			dec/=16;	// what does that mean?
		}
		System.out.println(hex);

	}



}

what does dec/=16 in the code means?

Recommended Answers

All 2 Replies

dec /= 16;

is equivalent to

dec = dec/16;

This is a standard short form for arithmetic operators.

ooh okay. now i remember this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.