• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 11:53
CEST 17:53
KST 00:53
  • 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
TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Weekly Cups (Oct 13-19): Clem Goes for Four0BSL Team A vs Koreans - Sat-Sun 16:00 CET6Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)80Weekly Cups (Sept 29-Oct 5): MaxPax triples up3
StarCraft 2
General
The New Patch Killed Mech! Team Liquid Map Contest #21 - Presented by Monster Energy herO joins T1 Weekly Cups (Oct 13-19): Clem Goes for Four TL.net Map Contest #21: Voting
Tourneys
SC2's Safe House 2 - October 18 & 19 INu's Battles #13 - ByuN vs Zoun Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $1,200 WardiTV October (Oct 21st-31st)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers
Brood War
General
BSL Season 21 BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ BW caster Sayle BSL Team A vs Koreans - Sat-Sun 16:00 CET
Tourneys
[ASL20] Semifinal B Azhi's Colosseum - Anonymous Tournament [Megathread] Daily Proleagues SC4ALL $1,500 Open Bracket LAN
Strategy
Current Meta BW - ajfirecracker Strategy & Training Relatively freeroll strategies Siegecraft - a new perspective
Other Games
General Games
Nintendo Switch Thread Path of Exile Stormgate/Frost Giant Megathread Dawn of War IV ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine Men's Fashion Thread Sex and weight loss
Fan Clubs
The herO Fan Club!
Media & Entertainment
Series you have seen recently... Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
Formula 1 Discussion 2024 - 2026 Football Thread MLB/Baseball 2023 NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
The Heroism of Pepe the Fro…
Peanutsc
Rocket League: Traits, Abili…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1626 users

The Big Programming Thread - Page 146

Forum Index > General Forum
Post a Reply
Prev 1 144 145 146 147 148 1032 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
Hyrule19144 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 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 7m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
LamboSC2 386
StarCraft: Brood War
Britney 42363
Calm 6390
Hyuk 4759
Sea 2976
Bisu 2700
GuemChi 1978
Horang2 1751
Flash 1388
Jaedong 1128
Larva 614
[ Show more ]
EffOrt 539
Soma 477
Light 393
Mong 335
Mini 234
actioN 232
Snow 202
Soulkey 179
hero 164
Hyun 160
TY 83
ggaemo 65
JYJ63
Barracks 46
Mind 41
sorry 39
Killer 37
Rush 34
Terrorterran 30
Aegong 26
Rock 17
soO 16
scan(afreeca) 15
Movie 15
Sacsri 15
SilentControl 14
Bale 10
Shine 9
yabsab 9
HiyA 5
Dota 2
Gorgc6967
qojqva4201
Dendi1213
420jenkins453
BananaSlamJamma169
canceldota58
Counter-Strike
byalli638
markeloff211
fl0m151
edward56
FunKaTv 31
Heroes of the Storm
Khaldor194
Other Games
singsing2427
hiko1278
B2W.Neo1089
FrodaN636
ceh9415
Lowko346
Sick340
Liquid`VortiX252
ArmadaUGS101
C9.Mang076
KnowMe70
XcaliburYe61
Mew2King51
Trikslyr38
Organizations
Counter-Strike
PGL537
StarCraft 2
WardiTV76
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• poizon28 40
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• Reevou 0
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 3353
Other Games
• Shiphtur101
Upcoming Events
Monday Night Weeklies
7m
Replay Cast
7h 7m
WardiTV Invitational
19h 7m
WardiTV Invitational
22h 37m
PiGosaur Monday
1d 8h
Replay Cast
1d 18h
Tenacious Turtle Tussle
2 days
The PondCast
2 days
OSC
2 days
WardiTV Invitational
3 days
[ Show More ]
Online Event
4 days
RSL Revival
4 days
RSL Revival
4 days
WardiTV Invitational
4 days
Afreeca Starleague
5 days
Snow vs Soma
Sparkling Tuna Cup
5 days
WardiTV Invitational
5 days
CrankTV Team League
5 days
RSL Revival
6 days
Wardi Open
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
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.