• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 21:05
CEST 03:05
KST 10:05
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL19] Finals Recap: Standing Tall9HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
[BSL20] Non-Korean Championship 4x BSL + 4x China1Flash Announces Hiatus From ASL63Weekly Cups (June 23-29): Reynor in world title form?13FEL Cracov 2025 (July 27) - $8000 live event22Esports World Cup 2025 - Final Player Roster16
StarCraft 2
General
Program: SC2 / XSplit / OBS Scene Switcher The SCII GOAT: A statistical Evaluation Statistics for vetoed/disliked maps Weekly Cups (June 23-29): Reynor in world title form? PiG Sty Festival #5: Playoffs Preview + Groups Recap
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
Player “Jedi” cheat on CSL SC uni coach streams logging into betting site Flash Announces Hiatus From ASL BW General Discussion Practice Partners (Official)
Tourneys
[BSL20] Non-Korean Championship 4x BSL + 4x China CSL Xiamen International Invitational The Casual Games of the Week Thread [BSL20] Grand Finals - Sunday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread What do you want from future RTS games? Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Summer Games Done Quick 2025! Trading/Investing Thread Things Aren’t Peaceful in Palestine
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 598 users

The Big Programming Thread - Page 146

Forum Index > General Forum
Post a Reply
Prev 1 144 145 146 147 148 1031 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
green.at
Profile Blog Joined January 2010
Austria1459 Posts
June 23 2012 20:00 GMT
#2901
does anyone have experience with multi-agent development, especially with JADE? If so, do you know how to connect directly to another platform over the net?
Inputting special characters into chat should no longer cause the game to crash.
ranshaked
Profile Blog Joined August 2010
United States870 Posts
Last Edited: 2012-06-24 03:24:05
June 24 2012 03:03 GMT
#2902
On June 22 2012 07:00 Abductedonut wrote:
Show nested quote +
On June 22 2012 06:12 ranshaked wrote:
I'm typing from my phone, so please bare with me. I had an assignment that I handed in that was not complete because I could not figure out how to do division. Basically the assignment is like this:
Randomly generate a math sign (+*/-) and two random numbers and ask the user to solve the problem. Everything works properly except the division. I know that it is because I'm using integers, but when I caste them as floats in my if or switch statements (tried both) it either gets 0.000000 all the time or it messes up the other integers. The final line needs to print the answer. Because it is random, I'm struggling with the final answer, everything will wok except division

I'll post the code later. Thanks


I whipped up some quick code for you. It's by no means pretty. Here you go. Assuming you're using C, same principles should apply in C++. Next time, specify which language you use!

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[]
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = rand()%4;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);

switch ( map[mathOperator] )
{
case '-':
result = randomNum - randomNum2;
break;
case '+':
result = randomNum + randomNum2;
break;
case '*':
result = randomNum * randomNum2;
break;
case '/':
result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %f ",result);
break;
}

//How come the divison never works??
//It's because of round-off errors within the computer. Trying looking at:
//http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %f \n",answer);
fflush(stdin);

if ( answer == result )
printf("Correct! \n");
}

return 0;
}



The basic idea between comparing floats is that you must have a general "error" range that you're okay with.

Most floats, when printed, will get rounded off. So it may seem like the answer is 1.3333334 but in memory its actually stored as 1.333333333333333333333. So when you do the comparison, it gets jacked up. Read the article I commented in the code.

Also, does anyone have expierence with Microsoft's Media Foundation? I've been trying to use MF to capture to a hwnd using D3D and I'm having a really hard time. Would appreciate any help.



Thank you very much, it definitely helped. Would also happen to know why when I type in an answer to a division problem exactly the way I printf the answer, that it still doesn't read it in as correct? Basically this is what is happening: I'll post an image. I have it set to debug in which it gives me the answer, then I type in the answer and it should say "correct!", but for some reason, I type in EXACTLY what it prints out the answer to be, and it's still reading it as wrong. Here's an image.
[image loading]

Thanks. I've tried using %.2f to limit it, %f, %lf and it's always random, some division problems will read my answers properly, and some won't. I marked the two that are not are opposite

Edit: I'm reading that you cannot directly compare floats :/ unless you use a function, but unfortunately I was never taught this!

Edit again: This happens with both your code, and my original "if" statements. The problem is this: If it's not division, the answer has to be an integer, but if it's division it has to be two decimal places, like 2.12...

When you're casting floats or doubles with (double) x / ((double)y) can you cast that directly to two decimal places? Like doing (double.2)x ?
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
Last Edited: 2012-06-24 03:56:19
June 24 2012 03:54 GMT
#2903
On June 24 2012 12:03 ranshaked wrote:
Show nested quote +
On June 22 2012 07:00 Abductedonut wrote:
On June 22 2012 06:12 ranshaked wrote:
I'm typing from my phone, so please bare with me. I had an assignment that I handed in that was not complete because I could not figure out how to do division. Basically the assignment is like this:
Randomly generate a math sign (+*/-) and two random numbers and ask the user to solve the problem. Everything works properly except the division. I know that it is because I'm using integers, but when I caste them as floats in my if or switch statements (tried both) it either gets 0.000000 all the time or it messes up the other integers. The final line needs to print the answer. Because it is random, I'm struggling with the final answer, everything will wok except division

I'll post the code later. Thanks


I whipped up some quick code for you. It's by no means pretty. Here you go. Assuming you're using C, same principles should apply in C++. Next time, specify which language you use!

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[]
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = rand()%4;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);

switch ( map[mathOperator] )
{
case '-':
result = randomNum - randomNum2;
break;
case '+':
result = randomNum + randomNum2;
break;
case '*':
result = randomNum * randomNum2;
break;
case '/':
result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %f ",result);
break;
}

//How come the divison never works??
//It's because of round-off errors within the computer. Trying looking at:
//http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %f \n",answer);
fflush(stdin);

if ( answer == result )
printf("Correct! \n");
}

return 0;
}



The basic idea between comparing floats is that you must have a general "error" range that you're okay with.

Most floats, when printed, will get rounded off. So it may seem like the answer is 1.3333334 but in memory its actually stored as 1.333333333333333333333. So when you do the comparison, it gets jacked up. Read the article I commented in the code.

Also, does anyone have expierence with Microsoft's Media Foundation? I've been trying to use MF to capture to a hwnd using D3D and I'm having a really hard time. Would appreciate any help.



Thank you very much, it definitely helped. Would also happen to know why when I type in an answer to a division problem exactly the way I printf the answer, that it still doesn't read it in as correct? Basically this is what is happening: I'll post an image. I have it set to debug in which it gives me the answer, then I type in the answer and it should say "correct!", but for some reason, I type in EXACTLY what it prints out the answer to be, and it's still reading it as wrong. Here's an image.

Thanks. I've tried using %.2f to limit it, %f, %lf and it's always random, some division problems will read my answers properly, and some won't. I marked the two that are not are opposite

Edit: I'm reading that you cannot directly compare floats :/ unless you use a function, but unfortunately I was never taught this!

Edit again: This happens with both your code, and my original "if" statements. The problem is this: If it's not division, the answer has to be an integer, but if it's division it has to be two decimal places, like 2.12...

When you're casting floats or doubles with (double) x / ((double)y) can you cast that directly to two decimal places? Like doing (double.2)x ?


You're thinking of it the wrong way. How you PRINT decimals to the screen and how the computer actually stores them are two completely different things. When you use printf, cout, whatever output you use, those functions are written to take the value inside the computer and print it in a way you specify. The printf family of functions doesn't particularly care if the value inside the computer is 2.999999999 or 3.0000000001. It will print out 3 if specify it to one digit.

Now when you do a comparison inside your program, such as:

if ( float1 == float2 )

Then the computer assumes that they must be the same at EVERY SINGLE DECIMAL SPACE PAST THE DECIMAL POINT. So as a concrete example, if float1 = 1.9999999999999999 and float2 = 1.9999999999999998 then as far as the computer is concerned, they are not equal. Whoops, your above if statement would fail. That is why floats need an acceptable margin for error. To you, float1 and float2 are pretty much the same. I mean, who cares about the 10th or 11th decimal place not being the same, right?

That is why the more LOGICAL equivalent for the comparison above is like this:

if ( ABSOLUTEVALUE( float1 - float2 ) <= 0.000000000001 )

This above comparison basically says "okay look, if these floats are the same up till this decimal point, then I pretty much consider them equal."

Well guess what? Everytime you call scanf, the value the user puts in, such as 1.24, it can actually get stored as 1.2399999999999999999999999. That is precisely why your program is failing, and that is precisely what that exercise is supposed to teach you. Here's working code, in case you need an even more concrete example:

+ Show Spoiler +

Here are some of the results when you run the code in the spoiler:
43 / 3 Result is: 14.33
What is the answer? 14.33
you entered: 14.3299999237
But trancted to two decimal places.. you entererd: 14.33
Correct!
50 / 4 Result is: 12.50
What is the answer? 12.50
you entered: 12.5000000000
But trancted to two decimal places.. you entererd: 12.50
Correct!
89 / 96 Result is: 0.93
What is the answer? 0.93
you entered: 0.9300000072
But trancted to two decimal places.. you entererd: 0.93
Correct!
38 / 44 Result is: 0.86
What is the answer? 0.86
you entered: 0.8600000143
But trancted to two decimal places.. you entererd: 0.86
Correct!
60 / 8 Result is: 7.50
What is the answer?

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[] )
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = 3;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);


result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %.2f ",result);

printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %.10f \n",answer);
printf("But trancted to two decimal places.. you entererd: %.2f \n",answer);
fflush(stdin);


if ( map[mathOperator] == '/' && ( (answer-result) <= 0.001 || result-answer <= 0.001) )
printf("Correct! \n");
}

return 0;
}


ranshaked
Profile Blog Joined August 2010
United States870 Posts
June 24 2012 04:03 GMT
#2904
On June 24 2012 12:54 Abductedonut wrote:
Show nested quote +
On June 24 2012 12:03 ranshaked wrote:
On June 22 2012 07:00 Abductedonut wrote:
On June 22 2012 06:12 ranshaked wrote:
I'm typing from my phone, so please bare with me. I had an assignment that I handed in that was not complete because I could not figure out how to do division. Basically the assignment is like this:
Randomly generate a math sign (+*/-) and two random numbers and ask the user to solve the problem. Everything works properly except the division. I know that it is because I'm using integers, but when I caste them as floats in my if or switch statements (tried both) it either gets 0.000000 all the time or it messes up the other integers. The final line needs to print the answer. Because it is random, I'm struggling with the final answer, everything will wok except division

I'll post the code later. Thanks


I whipped up some quick code for you. It's by no means pretty. Here you go. Assuming you're using C, same principles should apply in C++. Next time, specify which language you use!

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[]
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = rand()%4;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);

switch ( map[mathOperator] )
{
case '-':
result = randomNum - randomNum2;
break;
case '+':
result = randomNum + randomNum2;
break;
case '*':
result = randomNum * randomNum2;
break;
case '/':
result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %f ",result);
break;
}

//How come the divison never works??
//It's because of round-off errors within the computer. Trying looking at:
//http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %f \n",answer);
fflush(stdin);

if ( answer == result )
printf("Correct! \n");
}

return 0;
}



The basic idea between comparing floats is that you must have a general "error" range that you're okay with.

Most floats, when printed, will get rounded off. So it may seem like the answer is 1.3333334 but in memory its actually stored as 1.333333333333333333333. So when you do the comparison, it gets jacked up. Read the article I commented in the code.

Also, does anyone have expierence with Microsoft's Media Foundation? I've been trying to use MF to capture to a hwnd using D3D and I'm having a really hard time. Would appreciate any help.



Thank you very much, it definitely helped. Would also happen to know why when I type in an answer to a division problem exactly the way I printf the answer, that it still doesn't read it in as correct? Basically this is what is happening: I'll post an image. I have it set to debug in which it gives me the answer, then I type in the answer and it should say "correct!", but for some reason, I type in EXACTLY what it prints out the answer to be, and it's still reading it as wrong. Here's an image.

Thanks. I've tried using %.2f to limit it, %f, %lf and it's always random, some division problems will read my answers properly, and some won't. I marked the two that are not are opposite

Edit: I'm reading that you cannot directly compare floats :/ unless you use a function, but unfortunately I was never taught this!

Edit again: This happens with both your code, and my original "if" statements. The problem is this: If it's not division, the answer has to be an integer, but if it's division it has to be two decimal places, like 2.12...

When you're casting floats or doubles with (double) x / ((double)y) can you cast that directly to two decimal places? Like doing (double.2)x ?


You're thinking of it the wrong way. How you PRINT decimals to the screen and how the computer actually stores them are two completely different things. When you use printf, cout, whatever output you use, those functions are written to take the value inside the computer and print it in a way you specify. The printf family of functions doesn't particularly care if the value inside the computer is 2.999999999 or 3.0000000001. It will print out 3 if specify it to one digit.

Now when you do a comparison inside your program, such as:

if ( float1 == float2 )

Then the computer assumes that they must be the same at EVERY SINGLE DECIMAL SPACE PAST THE DECIMAL POINT. So as a concrete example, if float1 = 1.9999999999999999 and float2 = 1.9999999999999998 then as far as the computer is concerned, they are not equal. Whoops, your above if statement would fail. That is why floats need an acceptable margin for error. To you, float1 and float2 are pretty much the same. I mean, who cares about the 10th or 11th decimal place not being the same, right?

That is why the more LOGICAL equivalent for the comparison above is like this:

if ( ABSOLUTEVALUE( float1 - float2 ) <= 0.000000000001 )

This above comparison basically says "okay look, if these floats are the same up till this decimal point, then I pretty much consider them equal."

Well guess what? Everytime you call scanf, the value the user puts in, such as 1.24, it can actually get stored as 1.2399999999999999999999999. That is precisely why your program is failing, and that is precisely what that exercise is supposed to teach you. Here's working code, in case you need an even more concrete example:

+ Show Spoiler +

Here are some of the results when you run the code in the spoiler:
43 / 3 Result is: 14.33
What is the answer? 14.33
you entered: 14.3299999237
But trancted to two decimal places.. you entererd: 14.33
Correct!
50 / 4 Result is: 12.50
What is the answer? 12.50
you entered: 12.5000000000
But trancted to two decimal places.. you entererd: 12.50
Correct!
89 / 96 Result is: 0.93
What is the answer? 0.93
you entered: 0.9300000072
But trancted to two decimal places.. you entererd: 0.93
Correct!
38 / 44 Result is: 0.86
What is the answer? 0.86
you entered: 0.8600000143
But trancted to two decimal places.. you entererd: 0.86
Correct!
60 / 8 Result is: 7.50
What is the answer?

+ Show Spoiler +


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(int argc, char *argv[] )
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = 3;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);


result = (float)randomNum / ( (float)randomNum2 );
printf(" Result is: %.2f ",result);

printf(" \nWhat is the answer? ");
scanf("%f",&answer);
printf("you entered: %.10f \n",answer);
printf("But trancted to two decimal places.. you entererd: %.2f \n",answer);
fflush(stdin);


if ( map[mathOperator] == '/' && ( (answer-result) <= 0.001 || result-answer <= 0.001) )
printf("Correct! \n");
}

return 0;
}



Thank you, this is much easier to understand than the things I've been reading. I understand now, I assumed that by using a float it automatically limited the answer to only 6 decimal places, I didn't realize that even though it doesn't show, it's still checking down the line.

I will try this and let you know. This stuff is fascinating, and challenging. I dislike how I've been stuck on this all day, but i'll play with it now. I actually enjoy spending hours trying to figure stuff out and playing with it, but sometimes I get stuck like this!
Abductedonut
Profile Blog Joined December 2010
United States324 Posts
June 24 2012 04:19 GMT
#2905
On June 24 2012 13:03 ranshaked wrote:
Thank you, this is much easier to understand than the things I've been reading. I understand now, I assumed that by using a float it automatically limited the answer to only 6 decimal places, I didn't realize that even though it doesn't show, it's still checking down the line.

I will try this and let you know. This stuff is fascinating, and challenging. I dislike how I've been stuck on this all day, but i'll play with it now. I actually enjoy spending hours trying to figure stuff out and playing with it, but sometimes I get stuck like this!


No problem. That's what this thread is for! Here's another really creative way you could have solved this problem, btw.

I feel like you'd like this.



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int main(int argc, char *argv[] )
{
int randomNum = 0, randomNum2 = 0, mathOperator = 0;
float result = 0, answer = 0;
srand ( time(NULL) );

char map[4] = {'-','+','*','/'};
char cool1[10], cool2[10];

while( 1 )
{
randomNum = rand()%100; //Truncated it to a limit of 100, so that you don't get ridiculous numbers...
printf("%i ",randomNum);
mathOperator = 3;
printf("%c ",map[mathOperator] );
randomNum2 = rand()%100;
printf("%i",randomNum2);


result = (float)randomNum / ( (float)randomNum2 );

sprintf(cool1,"%.2f",result);
printf(" Your answer: ");
scanf("%f",&answer);
sprintf(cool2,"%.2f",answer);
fflush(stdin);

if ( !strcmp(cool1,cool2) )
printf("Correct! \n");

}

return 0;
}
Ghad
Profile Blog Joined April 2010
Norway2551 Posts
June 24 2012 21:21 GMT
#2906
The official Video Torrent from NDC Oslo 2012 with 87 gigs of free development videos is now up. You are welcome.

http://www.ndcoslo.com/Article/News/2012video
forgottendreams: One underage girl, two drunk guys, one gogo dancer and starcraft 2. Apparently just another day in Europe.
Iwbhs
Profile Blog Joined May 2009
United States195 Posts
June 25 2012 00:12 GMT
#2907
http://pastebin.com/myhvzy1q

Any idea on why my tooltip breaks when I include html?
Everyone loves Milano cookies.
berated-
Profile Blog Joined February 2007
United States1134 Posts
June 25 2012 00:19 GMT
#2908
On June 25 2012 09:12 Iwbhs wrote:
http://pastebin.com/myhvzy1q

Any idea on why my tooltip breaks when I include html?


Looks like you need to escape your quotes.

onmouseover="doStuff(\"escape me \")"
Iwbhs
Profile Blog Joined May 2009
United States195 Posts
Last Edited: 2012-06-25 00:24:10
June 25 2012 00:22 GMT
#2909
<div id="shoulder" ONMOUSEOVER="ddrivetip('1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1<br />','black')"; ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


where is the mistake in quotes?

<div id="shoulder" ONMOUSEOVER="ddrivetip('1 Armor<br /><a href=\"/class.php?c=Monk&d=Shoulder\">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1\n','black')"; ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


not working.
Everyone loves Milano cookies.
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2012-06-25 00:59:56
June 25 2012 00:45 GMT
#2910
On June 25 2012 09:22 Iwbhs wrote:
<div id="shoulder" ONMOUSEOVER="ddrivetip('1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1<br />','black')"; ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


where is the mistake in quotes?

<div id="shoulder" ONMOUSEOVER="ddrivetip('1 Armor<br /><a href=\"/class.php?c=Monk&d=Shoulder\">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1\n','black')"; ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


not working.


yeah mental lapse, you can't use \ in html, you would have to escape it using html &quot;. The best way to avoid this is probably restructure your code a little bit, but thats a different argument.

To get it working pick one quote for the outside and one for the inside, what I mean by that is..

<div id="shoulder" ONMOUSEOVER='ddrivetip("1 Armor<br /><a href=\"/class.php?c=Monk&d=Shoulder\">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1\n","black");' ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>


You also have to escape the quote for the js


Edit: Yeah okay this is painful a couple questions...

1) Is there any reason you aren't using jquery?

2) Even if you aren't using jquery you can still accomplish this. It would probably be cleaner if you hid the html that you wanted to use in a div somewhere on the page and then grabbed it load the tip.

Example: ( I didn't test this, just trying to show the general concept )

<div id="shoulder" ONMOUSEOVER="ddrivetip('tooltiptext','black');" ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>



<div id="tooltiptext" style="display:none">
1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1
</div>



function ddrivetip(theid, thecolor, thewidth){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=document.findElementById(theid).innerHTML
enabletip=true
return false
}




3FFA
Profile Blog Joined February 2010
United States3931 Posts
June 25 2012 01:24 GMT
#2911
I'm starting to learn programming today with Java. I am being taught the basics by my older brother and he gave me a program to use called Eclipse. Is there any good tips I could get for someone starting out learning Java? Has anyone used Eclipse before? I also am testing myself as I learn with codingbat.com. Is there any other sites like that for Java? Do note that I didn't read the thread other than the OP. Sorry for that.
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
tofucake
Profile Blog Joined October 2009
Hyrule19031 Posts
June 25 2012 01:30 GMT
#2912
Eclipse is pretty standard for Java. Unfortunately it's got a lot of features you'll probably not use which slow it down considerably. Just poke around some tutorials. Buy a Java book if you're serious about learning Java. If you're like me (learn by doing), I suggest a mid level book rather than a For Dummies or whatever. Check this out
Liquipediaasante sana squash banana
3FFA
Profile Blog Joined February 2010
United States3931 Posts
Last Edited: 2012-06-25 01:39:41
June 25 2012 01:37 GMT
#2913
Ok thanks a lot! Also, I will be learning C++ come September in my High School because I got the highest test grades in my class and was able to qualify for it (of course said yes immediately as I've always been interested in programming) so that led to me asking my brother if I could learn a language that he knows. My plan is to learn a good amount of Java this summer and many years down the road my plan is to make an RTS game. However, I will of course make a lot of much simpler stuff first.

I've already been told how things like a 1 instead of an i can mess up coding so much that you may spend hours asking people to help you look through it, possibly even a whole day.
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
June 25 2012 01:43 GMT
#2914
Wait until you can't find the = that's supposed to be a == ....

-_____-"
There is no one like you in the universe.
Azerbaijan
Profile Blog Joined January 2010
United States660 Posts
June 25 2012 02:46 GMT
#2915
Can anyone reccomend a good book for learning C? The one I have is from the 70s.
jergason
Profile Joined May 2010
United States37 Posts
June 25 2012 04:56 GMT
#2916
The C Programming Language is the best book on C, and one of the best programming books ever written.

http://www.amazon.com/C-Programming-Language-2nd-Edition/dp/0131103628/ref=sr_1_1?ie=UTF8&qid=1340600201&sr=8-1&keywords=the c programming language
supereddie
Profile Joined March 2011
Netherlands151 Posts
Last Edited: 2012-06-25 10:00:35
June 25 2012 09:59 GMT
#2917
On June 25 2012 09:45 berated- wrote:

2) Even if you aren't using jquery you can still accomplish this. It would probably be cleaner if you hid the html that you wanted to use in a div somewhere on the page and then grabbed it load the tip.

Example: ( I didn't test this, just trying to show the general concept )

<div id="shoulder" ONMOUSEOVER="ddrivetip('tooltiptext','black');" ONMOUSEOUT="hideddrivetip()" style="background-image: url(images/Shoulder.png);"></div>



<div id="tooltiptext" style="display:none">
1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1
</div>



function ddrivetip(theid, thecolor, thewidth){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=document.findElementById(theid).innerHTML
enabletip=true
return false
}



Even easier is just use CSS.

<style type="text/css">
.tooltiptext{ display: none; position: fixed; top: 0; right: 0; }
.tt:hover .tooltiptext{ display: block; }
</style>

...

<div class="tt" id="shoulder" style="background-image: url(images/Shoulder.png);">
<div class="tooltiptext">
1 Armor<br /><a href="/class.php?c=Monk&d=Shoulder">Shoulder</a><br />&nbsp;&nbsp;&nbsp;All Resistance: 1
</div>
</div>

Ofcourse, this won't work in Internet Explorer < 8, but it works in any recent browser so who cares?
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
Poltergeist-
Profile Blog Joined May 2010
Sweden336 Posts
June 25 2012 10:10 GMT
#2918
What are the latest and greatest/upcoming programming languages, if any? Anyone have any idea? Does it differ possibly between the US and EU?
Joefish
Profile Joined July 2010
Germany314 Posts
June 25 2012 17:03 GMT
#2919
On June 25 2012 19:10 Poltergeist- wrote:
What are the latest and greatest/upcoming programming languages, if any? Anyone have any idea? Does it differ possibly between the US and EU?


According to this website, the top 3 are C/Java/C++.
And I don' think there is any difference between different regions. But haven't found any data about it.
I'm actually surprised C being at the top of the charts. Thought top 3 would look like this C++/Java/PHP.
Isualin
Profile Joined March 2011
Germany1903 Posts
June 25 2012 17:13 GMT
#2920
any idea why C is getting bigger? isn't it quite old?
| INnoVation | The literal god TY | ByuNjwa | LRSL when? |
Prev 1 144 145 146 147 148 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 9h 55m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 214
Livibee 208
RuFF_SC2 78
ProTech74
StarCraft: Brood War
Artosis 1128
Icarus 6
Dota 2
monkeys_forever667
Counter-Strike
tarik_tv7163
Fnx 1821
Stewie2K977
Super Smash Bros
Mew2King140
Heroes of the Storm
Khaldor239
Other Games
summit1g10102
fl0m765
ViBE246
Maynarde177
JuggernautJason20
Organizations
Other Games
gamesdonequick46739
BasetradeTV56
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• davetesta35
• Berry_CruncH13
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• Ler60
League of Legends
• masondota2795
Upcoming Events
Wardi Open
9h 55m
Replay Cast
22h 55m
Sparkling Tuna Cup
1d 8h
WardiTV European League
1d 14h
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
1d 22h
The PondCast
2 days
WardiTV European League
2 days
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
2 days
Replay Cast
2 days
RSL Revival
3 days
ByuN vs SHIN
Clem vs Reynor
[ Show More ]
Replay Cast
3 days
RSL Revival
4 days
Classic vs Cure
FEL
4 days
RSL Revival
5 days
FEL
5 days
FEL
5 days
Sparkling Tuna Cup
6 days
RSL Revival
6 days
FEL
6 days
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Disclosure: This page contains affiliate marketing links that support TLnet.

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.