Should be fine. Java 6 didn't add any new language features, and most of the new library classes are not important to first time programmers. Java 7 did add some useful stuff (I think collections have been changed), but Java 7 isn't widely used at the moment. It's not even available on OS X.I think we're technically on Java 7 now, but Java 6 would be a minimum. If you learn from a Java 5 book, you're likely going to be taught a few things that are deprecated in later versions.
no its not that big, i ve limited the values to <31. all my program does is takes a string of binary numbers and converts it. its just a small little program with a gui, that only accepts 0's and 1'sLooks like usea has it covered for the most part, but I'm curious about an aspect of your program. How large is the binary string you're getting? Will it always be "small" values like 1010? Or are we talking binary strings that might get into the hundreds. Remember, integers can only hold so many bits...
For example, the decimal bit representation of the relatively small string :"I need help Gaf!" far eclipses the maximum size an Integer or even a Long can hold.
If you want to handle potentially large inputs, you can utilize the BigInteger class. This can handle - let's just say - very large number values.
So this will work not only for the small values, but also the large ones if your program is allowing the possibility of that. Downside is that of course BigIntegers are a bit more memory hungry than your normal primitive value. Of course, you can institute size checks on your input before you do any converting to see if you'll need an Integer, Long, or BigInteger, and then program accordingly.
its not as if i don't care, its just that i can take care of spelling and spacing at the end. yes i know i have spelling errors. i know that because i can't spell. that doesn't make me lazy. and yes i have googled and the most common response i get is use a NumberFormatException try and catch handler , google is a mixed bag of advise at times. i am sorry i made it so difficult, i didn't mean for it to be.Please don't take this the wrong way, I'm genuinely trying to help
Have you tried googling your problem?
When you're asking for help with some code, you have to post the code. Nobody can see it otherwise.
I want to help you, but you have made it very difficult.
Spelling is important when you're programming. Details are important.
If you don't want to figure out anything, you just want to "get it working" without caring, why should other people care to help when you don't? Care about what you're doing. Pay attention. Read error messages. Read the code. Read examples online. Google your problem. Make an effort.
Again, not trying to be rude or offend you. I am just trying to help.
String old = tField.getText();
Integer val = Integer.valueOf(old, 2);
String temp = new String();
if(oct.isSelected()){
temp = Integer.toString(val,8); //oct
flag = 1;
}
...etc (same if statement different radix values)
tField.setText(temp);
Sorry. I didn't mean to sound harsh.no its not that big, i ve limited the values to <31. all my program does is takes a string of binary numbers and converts it. its just a small little program with a gui, that only accepts 0's and 1's
its not as if i don't care, its just that i can take care of spelling and spacing at the end. yes i know i have spelling errors. i know that because i can't spell. that doesn't make me lazy. and yes i have googled and the most common response i get is use a NumberFormatException try and catch handler , google is a mixed bag of advise at times. i am sorry i made it so difficult, i didn't mean for it to be.
if you still wanna see the code, here it is.
Code:String old = tField.getText(); Integer val = Integer.valueOf(old, 2); String temp = new String(); if(oct.isSelected()){ temp = Integer.toString(val,8); //oct flag = 1; } ...etc tField.setText(temp);
nope still getting NumberFormatException. guess ill just ask around tomorrow. its fine. any help is appreciatedSorry. I didn't mean to sound harsh.
Did you get it working? The code looks reasonable to me.
what ever the last converted value was. so lets say 10101 -> (dec) 21 ->(hex) errorWhat are the exact values of old, val and temp when the exception is thrown?
If nothing else, use toOctalString(int i) instead.
String bin = "10101";
Integer i = Integer.valueOf(bin, 2);
System.out.println(i);
System.out.println(Integer.toString(i, 8));
System.out.println(Integer.toString(i, 16));
/* Output: 21
25
15 */
This is almost certainly incorrect. Have you actually looked at the values, or are you just guessing? Print them out after each line to be sure. Or step through with a debugger.what ever the last converted value was. so lets say 10101 -> (dec) 21 ->(hex) error
String old = "10101";
Integer val = Integer.valueOf(old, 2);
String temp = Integer.toString(val,16);
System.out.println(old + ", " + val + ", " + temp);
I use visual studio with mostly default settings. And Linqpad. Sometimes Notepad++. They all look default and not special at all.
I think I would die if I had to use a white background for my code all day.
it's fine. I hav no problem showig you my code. If you wanna see it, I'll paste bin it when I get home. Don't worry about it though. I'll just take care of this in class tomrrow.edit: to be more clear: replace this line
String old = tField.getText();
with this line:
String old = "10101";
And your program will probably work (except ignore what's in the text field). I'm betting the field is giving you some extra character(s) such as new lines or something. Either that or you're typing something other than 0s and 1s.
Ah I see. Well if you get stuck let us know. Don't mind helping at all. It's a nice break from work, and I haven't done java in ~2 years.it's fine. I hav no problem showig you my code. If you wanna see it, I'll paste bin it when I get home. Don't worry about it though. I'll just take care of this in class tomrrow.
Also I think you toke my example too literally. I ment to say that the user inputs a binary string which gets converted to w/e, let's say hex. The problem is that the hex value is sent to the text field and when I press enter, to convert from one value to another (not binary) , again it takes the converted value from the text field and gives an error.
Will do. Worst comes to worst, I'll store the binary string in a pravite var which stored in the main. untill the user clears it.Ah I see. Well if you get stuck let us know. Don't mind helping at all. It's a nice break from work, and I haven't done java in ~2 years.
I use visual studio with mostly default settings. And Linqpad.Sometimes Notepad++.They all look default and not special at all.
I use visual studio with mostly default settings. And Linqpad. Sometimes Notepad++. They all look default and not special at all.
No. Fuck the windows 8 store.Same here.
Anyone here thinking of writing anything for the Windows 8 Store ? Had this pop up on my Facebook wall today (Windows 8: Applications for the UK Windows Store)and thought about giving it a shot. Still got no idea what to go for but I'm sure I can think of something.
var t = Task.Factory.StartNew(() => "inside task".Dump());
Thread.Sleep(1000);
t.Status.Dump("status after sleep");
t.ContinueWith((x) => "new continuation".Dump());
Is there any advantage to using c style arrays over c++ arrays?
class Table {
public:
Table(Model& X, Converter& Y);
Model& getModel();
Converter& getConverter();
private:
vector<Entry*> entries;
Model& m_Model;
Converter& m_Converter;
};
class Entry {
public:
Entry(value_t entryValue, Table& table);
private:
Value m_Value;
Table& m_Table;
Model& m_Model;
Converter& m_Converter;
};
Table::Table(Model& X, Converter& Y)
: m_Model(X),
m_Converter(Y)
{
entries.push_back(new Entry(FIRST_VALUE, *this));
entries.push_back(new Entry(SECOND_VALUE, *this));
entries.push_back(new Entry(THIRD_VALUE, *this));
.
.
.
}
Entry::Entry(value_t entryValue, Table& table)
: m_Value(entryValue),
m_Table(table),
m_Model(m_Table.getModel()),
m_Converter(m_Table.getConverter())
{
// empty constructor
}
Same here.
Anyone here thinking of writing anything for the Windows 8 Store ? Had this pop up on my Facebook wall today (Windows 8: Applications for the UK Windows Store)and thought about giving it a shot. Still got no idea what to go for but I'm sure I can think of something.
#Header {
position: fixed; height: 32px;
@media print {
display: none;
}
}
So, gaf, I'm a software engineer that regularly works with C++. a friend of mine (Electrical Engineer) asked me to help debug this C++ code his little brother (Also a friend of mine, and he's currently studying Computer Science) wrote... I'm a little embarrassed to say that I don't see the issue, but I think this is one of those gotchas involving initialization lists. The code compiles properly but, when executed, it cores when attempting to execute the highlighted line (Illegal Instruction) and I can't for the life of me explain why, or how to fix the issue.
I've only included the relevant portions of his code (First a shortened class outline of the Table and Entry classes, and the constructors and relevant fields).
Code:class Table { public: Table(Model& X, Converter& Y); Model& getModel(); Converter& getConverter(); private: vector<Entry*> entries; Model& m_Model; Converter& m_Converter; }; class Entry { public: Entry(value_t entryValue, Table& table); private: Value m_Value; Table& m_Table; Model& m_Model; Converter& m_Converter; }; Table::Table(Model& X, Converter& Y) : m_Model(X), m_Converter(Y) { entries.push_back(new Entry(FIRST_VALUE, *this)); entries.push_back(new Entry(SECOND_VALUE, *this)); entries.push_back(new Entry(THIRD_VALUE, *this)); . . . } Entry::Entry(value_t entryValue, Table& table) : m_Value(entryValue), m_Table(table), m_Model(m_Table.getModel()), m_Converter(m_Table.getConverter()) { // empty constructor }
Anyone spot the problem? I've forgotten quite a bit about initialization lists, and the fact that the issue pops up on the second entry rather than the first seems REALLY odd.
Is there any advantage to using c style arrays over c++ arrays?
#include"Boss.h"
void main()
{
int stop = 0;
Enemy enemy[10];
cout << "Chapter one : Inheritance and Polymorphism\n\n";
//initialise the enemy array with both Enemy AND Boss
for(int i = 0; i < 3; i++)
{
enemy[i] = Enemy();
}
for(int i = 4; i < 7; i++)
{
enemy[i] = Boss();
}
for(int i = 8; i < 10; i++)
{
enemy[i] = Enemy();
}
//call the Array and print out its entityAI method
for(int i = 0; i < 10; i++)
{
enemy[i].entityAI();
}
cin >> stop;
}
#include <Windows.h>
#include <iostream>
#include <sstream>
#include <fstream>
using namespace std;
class Enemy
{
private:
protected:
int health;
public:
Enemy();
virtual void entityAI();
};
#include "Enemy.h"
Enemy::Enemy()
{
health = 0;
}
void Enemy::entityAI()
{
cout << "I am an enemy, ";
}
#include "Enemy.h"
class Boss : public Enemy
{
private:
protected:
public:
Boss();
void entityAI();
};
#include "Boss.h"
Boss::Boss()
{
health = 0;
}
void Boss::entityAI()
{
Enemy::entityAI();
cout << "but I am a boss !\n";
}
Well the other night I decided I was going to make a proper attempt at nailing down OO techniques for C++. So I tried to do some Polymorphism and I can't seem to get my method to Override in my "child" class. It's probably just a small syntactical problem but any help is great !
Main :
Code:CODE
You need an array of pointers or references. There is no vtable look up with a value type.
So, gaf, I'm a software engineer that regularly works with C++. a friend of mine (Electrical Engineer) asked me to help debug this C++ code his little brother (Also a friend of mine, and he's currently studying Computer Science) wrote... I'm a little embarrassed to say that I don't see the issue, but I think this is one of those gotchas involving initialization lists. The code compiles properly but, when executed, it cores when attempting to execute the highlighted line (Illegal Instruction) and I can't for the life of me explain why, or how to fix the issue.
I've only included the relevant portions of his code (First a shortened class outline of the Table and Entry classes, and the constructors and relevant fields).
// code
Anyone spot the problem? I've forgotten quite a bit about initialization lists, and the fact that the issue pops up on the second entry rather than the first seems REALLY odd.
I'm pretty sure a lot of compilers won't warn about the initialization list order. I just like to be cautious when coding.I'm pretty sure you removed the problem when you simplified it. Were there any virtual calls? Also, if he isn't doing it already, he should be compiling with -wAll and -Werror (or equivalent). Lathentar's worries about initialization list order can be caught by the compiler, so there's no reason to avoid depending on it.
June 18, 2012 - We're pleased to announce the first public Beta release of OpenEXR v2.
Development of OpenEXR v2 has been undertaken in a collaborative environment (cf. previous github announcement) comprised of Industrial Light and Magic, Weta Digital as well as a number of other contributors.
Some of the new features included in the Beta.1 release of OpenEXR v2 are:
* Deep Data. Pixels can now store a variable length list of samples. The main rationale behind deep-images is to have multiple values at different depths for each pixel. OpenEXR v2 supports both hard surface and volumetric representation requirements for deep compositing workflows.
* Multi-part image files. With OpenEXR v2, files can now contain a number of separate, but related, images in one file. Access to any part is independent of the others; in particular, no access of data need take place for unrequested parts.
In addition, OpenEXR v2 also contains platform independent mechanisms for handling co-existing library version conflicts in the same process space. (Currently implemented in IlmImf)
Finally, a reminder that this is a Beta release and potentially incompatible changes may be introduced in future releases prior to the v2.0.0 production version.
OpenEXR v2Beta.1 can be found at: https://github.com/openexr/openexr/tree/v2_beta.1
I'm pretty sure a lot of compilers won't warn about the initialization list order. I just like to be cautious when coding.
int interpolate(int cx, int cy, int cz)
{
float percent = (float)cz / 128.0f;
int range = cy - cx;
float interpolation = cx + (range * percent);
return floor(interpolation + 0.5f); //this rounds. is the 'f' necessary? I don't really know c++
}
first make a double or float that is CZ / 128.
float percentage = (float)CZ / 128.0;
Then get the range of CX to CY (I'm assuming CX will always be less than CY. otherwise figure out which is smaller first).
int range = CY - CX;
Then multiply difference times percentage, and add that to CX (or CY if it's smaller).
float interpolation = CX + (difference * percentage);
Code:int interpolate(int cx, int cy, int cz) { float percent = (float)cz / 128.0f; int range = cy - cx; float interpolation = cx + (range * percent); return floor(interpolation + 0.5f); //this rounds. is the 'f' necessary? I don't really know c++ }
The reason for all this is because your CZ is the amount you want to interpolate by right? So if it's 64 you want 50% between CX and CY. How do you make 64 = 50%, 128 = 100%, 0 = 0% ? You just divide CZ by 128.
Now that you have the percent, how do you apply it? 50% should be half-way between CX and CY. How do you get 15 from 10, 20 and 0.5? It's half of the distance between the two, or in other words half the difference. So you need the difference (CY - CX). Now just apply the 0.5 to the difference and add it back in.
double pi = 4.0*atan(1);
It's also worth mentioning that your rounding method, floor(value + 0.5f), will round -0.5f to 0.0. This means that interpolate(10,20,96)=18 and interpolate(-10,-20,96)=-17. It's not immediately clear to me from the original question if or how negative numbers should be handled.
EDIT: Actually, there's another thing. The Rusty0 specified cz should be 0-127. The first line should be float percent = cz / 127.0f; Otherwise interpolate(0,300,127)=298. This is why we write tests.
I think this is the best thread to ask: I am nearing my graduation here in Germany. One year to go. Now I am trying to figure out what I should study. I am between three subjects: Math, Physic or computer science. I prefer computer science because it looks interesting and contains math. But the problem is, I never programmed. I do not know a computer language. That's the reason why I want to start learning one. But at the end, there are tons of books, websites etc. and the reviews of the books do say some confusing things (like this book is perfect for starters, next review: This book is definitely not for starters etc.)
So with which language should I start? Which websites or books can you guys recommend?
Is there any way use variable as type?
I have this calculation which depends on the variable type and I want to make it simpler than using IF-statements.
example:
int Type = Green;
int Green = Green_Rating(3);
int Blue = Blue_Rating(1)
int Red = Red_Rating(1);
The calculation is 1+8*Type; // Here it uses Green's integer value for the result.
But the problem is that I also want it to behave differently in an IF-statement,
if (Type == Blue), should not compare the integers, but compare whether Type variable is Blue or not.
That's not neccessarily a problem. It helps to have a bit of foreknowledge, but they will teach you everything even if you don't.But the problem is, I never programmed. I do not know a computer language.
I've been seeing python being recommended more and more as a first language. Learn Python the Hard Way is supposedly a good guide and is free.So with which language should I start? Which websites or books can you guys recommend?
The question I tried to ask was: How to start learning a computer language. I know that it is not going to be all about math. II am assuming you mean you are graduating from equivalent of high school and want to decide what to study in college?
Most people are not sure about this even to the moment they graudate university, my advice is:
- Try writing a game, if you cannot finish it, you might not be good for software engineering (there are a bunch of tutorials online like this one http://create.msdn.com/en-US/education/tutorial/2dgame/getting_started )
- If you like the application of math and science to real world problem solving, there are so many possible job paths it is insane, so you should find mentors and find out what you are passionate about
- Computer science is not all about math - well, if you stay in academics it might be...but you need some amount of langauge writing and creation ability to be good at doing stuff with your computer science knowledge...do you like to write? does staring at words for hundreds of hours sound boring to you?
Ah you're right, totally missed that. Thanks.EDIT: Actually, there's another thing. The Rusty0 specified cz should be 0-127. The first line should be float percent = cz / 127.0f; Otherwise interpolate(0,300,127)=298. This is why we write tests.
Anyone familiar with SQL (working with Oracle), any easy way to drop all tables in a DB/user, regardless of constraints. It would help testing some scripts...
What language is this?
"Type" is an int, so it shouldn't matter what type of variable gave it its int value. As long as Type=Green is a valid assignment, Type "forgets" where it got its value from once the assignment is complete. Also, "Blue" is not a variable of type "Blue", but a variable of type "int". The fact that it's called "Blue" shouldn't matter, what if you change the name later on?
C. Type is a name of the variable. The idea is that Blue is constant. I guess the better example of what I am trying to do is, yeah it's actually really similar to that.
Think I have a pokemon of grass type against a pokemon of water type. I want to compare their types AND use the same variable to calculate bonus damage(int).
I can come up with a large chunk of code to get the result, but I'm challenging myself to find most simplest possible solution to this and now I can't get it out of my head.