0
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?

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by NewOrder
0

dec /= 16;

is equivalent to

dec = dec/16;

This is a standard short form for arithmetic operators.

Edited by jon.kiparsky: typo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.