Language…
22 users online: crocodileman94, D1STYNCT, DanMario24YT, Dennsen86, deported, Domokun007, GamesInTweed, Green, GRIMMKIN, Heitor Porfirio,  idol, Knetog, Maw, Nayfal,  Noivern, Pink Gold Peach, ppp9q, Silver_Revolver, test212,  Thomas, VSmario90, yoshiatom - Guests: 310 - Bots: 300
Users: 64,795 (2,374 active)
Latest user: mathew

New question...

How do you define an integer as a hexadecimal number in Java? I heard something about just putting "0x" before it, but...does it stay in hexadecimal once you define it as such? And how do you set preference for lowercase/capital letters? (For example, can you make sure that 0xB7 always shows up as "B7", never "b7"?)

Like...say I simply wanted to print out a table of the hexadecimal numbers 00-1F.

for(int hexVar = ?1?, hexVar <= ?2?, hexVar++)
{
System.out.print("$" + ?3? + ",");
if (hexVar % 8 = 7)
System.out.print(\n);
}

The define I labeled as "?1?" would be the starting hexadecimal value of the variable, "?2?" would be 32 or 0x20 written however, and ?3? would be the hexadecimal value with no signs or extra symbols or any kind. How would I write these? Or...say I wanted to convert a number from decimal to hexadecimal and back again. What subroutine, function, whatever, would I use? In fact, am I even supposed to define it as a normal integer, or are hexadecimal numbers a class like strings are?

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.

Code
class hexDump{
	public static void main(String[] args){
		String pre = "";
		for(int hexVar = 0x00; hexVar <= 0x1f; hexVar++){
			if(hexVar < 0x10)
				pre = "0";
			else
				pre = "";
			System.out.print("$"+pre+Integer.toHexString(hexVar).toUpperCase());
			if(hexVar != 0x1f)
				System.out.print(",");
			if(hexVar %8 == 7)
				System.out.println();
		}
	}
}
Integer.toHexString() will convert the hex number into an actual hex value and toUpperCase() will make sure that the number is always in capital letters.


Okay. Thank you.

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
also i think hex numbers have 0x at the start.
Originally posted by Biohaxard
also i think hex numbers have 0x at the start.


also i think you should check how old a thread is before you respond to it. obviously this question was answered at least half a year ago. chances are likely that this person no longer cares or could even be dead by now. things happen. anyway, please dont bump threads that are older than a couple of weeks unless you have something amazingly spectacular to add to the conversation - and even then think twice.

welcome to the site, though. we hope you enjoy your stay. just please review the rules.

[?] Miscellaneous Helpful Hints
If I moderated your hack, there was apparently a 90 percent chance it was rejected.
Hm. The hexadecimal thing will no doubt come up again in the future, but for now, I have another question: Can anyone recommend me a good tutorial on making GUIs in C++ (preferably with the Windows API)? I'm having a heck of a time just trying to find a good compiler.

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.

Immediately, my suggestion is to not make a GUI program in C++, because it will be hell.

Coding a GUI program is a bloody nightmare: you won't understand half the stuff you write. Therefore, I recommend using wxWidgets. However, if you want to use the Windows API, you can start here.


Originally posted by Yakov
Immediately, my suggestion is to not make a GUI program in C++, because it will be hell.

Hm...what would you recommend, then? I thought maybe I should stay away from C#, and although I have some experience with Java, it really doesn't have any features that stand out to me. What does that leave? Python?

Originally posted by Yakov
Coding a GUI program is a bloody nightmare: you won't understand half the stuff you write. Therefore, I recommend using wxWidgets. However, if you want to use the Windows API, you can start here.

Hm...okay. What about Qt? Do you know anything about it?

----------------

I'm working on a hack! Check it out here. Progress: 64/95 levels.
Originally posted by Yakov
Immediately, my suggestion is to not make a GUI program in C++, because it will be hell.


I have three things to say to that.
1. Citation need(aka who says)
2. The "degree" of difficulty is not based under one category. In fact I have found through personal experience C++ to have a BETTER environment for GUIs (templates and OO are a wonderful pair for this)
3. You have far more GUI options than in other languages, on top of that if you wanted you could implement your own.


My opinion: Stick to C++, using a tool kit like Qt or WxWidgets are great options. Qt has Amazing documentation and a clean API for development. There are several other options too, and even more advanced options like openGL.

Believe me, I tried coding in C++ using Windows API, Qt, and Wx. Windows API is quite impossible to understand unless you have millions upon millions of comments, and Qt is a bloody joke (well, at least with the Qt editor... damn hooks). While it's extremely easy to design a GUI and events with Wx and CodeBlocks, for everything else you'll need an extremely good understanding of C++. Did I mention you need to compile the Wx package, which takes half an hour?

Now, I'm designing a/n SMA3 editor using Wx and Perl, and I'm OK with that (the only problem I have is that the DLLs are like 5MB, which you must distribute). Lots of people were also recommending using Python because it's easy, you may want to check that out.

Overall, I'm not going to force you into which language and GUI to use, as everyone has their own preferences. I'm fine with what I'm good with, and I don't need to research "how do I open a file in C++" every 5 seconds.


Originally posted by Yakov
Believe me, I tried coding in C++ using Windows API, Qt, and Wx. Windows API is quite impossible to understand unless you have millions upon millions of comments, and Qt is a bloody joke (well, at least with the Qt editor... damn hooks). While it's extremely easy to design a GUI and events with Wx and CodeBlocks, for everything else you'll need an extremely good understanding of C++. Did I mention you need to compile the Wx package, which takes half an hour?

Now, I'm designing a/n SMA3 editor using Wx and Perl, and I'm OK with that (the only problem I have is that the DLLs are like 5MB, which you must distribute). Lots of people were also recommending using Python because it's easy, you may want to check that out.

Overall, I'm not going to force you into which language and GUI to use, as everyone has their own preferences. I'm fine with what I'm good with, and I don't need to research "how do I open a file in C++" every 5 seconds.



Question: How long had you used C++ before attempting a GUI?

Also: Qt uses SIGNALS and SLOTS not hooks...