• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 01:55
CET 07:55
KST 15:55
  • 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
RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13
Community News
[TLMC] Fall/Winter 2025 Ladder Map Rotation12Weekly Cups (Nov 3-9): Clem Conquers in Canada4SC: Evo Complete - Ranked Ladder OPEN ALPHA8StarCraft, SC2, HotS, WC3, Returning to Blizzcon!45$5,000+ WardiTV 2025 Championship7
StarCraft 2
General
Zerg is losing its identity in StarCraft 2 Mech is the composition that needs teleportation t RotterdaM "Serral is the GOAT, and it's not close" RSL Season 3 - RO16 Groups C & D Preview [TLMC] Fall/Winter 2025 Ladder Map Rotation
Tourneys
RSL Revival: Season 3 Sparkling Tuna Cup - Weekly Open Tournament Constellation Cup - Main Event - Stellar Fest Tenacious Turtle Tussle Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 499 Chilling Adaptation Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection
Brood War
General
FlaSh on: Biggest Problem With SnOw's Playstyle BGH Auto Balance -> http://bghmmr.eu/ What happened to TvZ on Retro? SnOw's ASL S20 Finals Review BW General Discussion
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] RO32 Group D - Sunday 21:00 CET [BSL21] RO32 Group C - Saturday 21:00 CET
Strategy
PvZ map balance Current Meta Simple Questions, Simple Answers How to stay on top of macro?
Other Games
General Games
Should offensive tower rushing be viable in RTS games? Path of Exile Stormgate/Frost Giant Megathread Nintendo Switch Thread Clair Obscur - Expedition 33
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
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread Artificial Intelligence Thread Canadian Politics Mega-thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion MLB/Baseball 2023 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
Blogs
Dyadica Gospel – a Pulp No…
Hildegard
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Reality "theory" prov…
perfectspheres
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1985 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
Hyrule19153 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
The PiG Daily
20:30
Best Games of SC
Serral vs Clem
Solar vs Cure
Serral vs Clem
Reynor vs GuMiho
herO vs Cure
LiquipediaDiscussion
OSC
19:00
Masters Cup #150: Group B
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 189
StarCraft: Brood War
actioN 683
Leta 317
Larva 275
EffOrt 92
yabsab 91
Bale 10
Dota 2
monkeys_forever591
XaKoH 186
NeuroSwarm107
League of Legends
JimRising 680
Other Games
summit1g14874
fl0m670
WinterStarcraft407
Fuzer 209
ViBE157
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH119
• practicex 30
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Stunt528
• HappyZerGling137
Other Games
• Scarra1294
Upcoming Events
Sparkling Tuna Cup
3h 5m
RSL Revival
3h 5m
Reynor vs sOs
Maru vs Ryung
Kung Fu Cup
5h 5m
Cure vs herO
Reynor vs TBD
WardiTV Korean Royale
5h 5m
BSL 21
13h 5m
JDConan vs Semih
Dragon vs Dienmax
Tech vs NewOcean
TerrOr vs Artosis
IPSL
13h 5m
Dewalt vs WolFix
eOnzErG vs Bonyth
Replay Cast
16h 5m
Wardi Open
1d 5h
Monday Night Weeklies
1d 10h
WardiTV Korean Royale
2 days
[ Show More ]
BSL: GosuLeague
2 days
The PondCast
3 days
Replay Cast
3 days
RSL Revival
4 days
BSL: GosuLeague
4 days
RSL Revival
5 days
WardiTV Korean Royale
5 days
RSL Revival
6 days
WardiTV Korean Royale
6 days
IPSL
6 days
Julia vs Artosis
JDConan vs DragOn
Liquipedia Results

Completed

Proleague 2025-11-14
Stellar Fest: Constellation Cup
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
CSCL: Masked Kings S3
SLON Tour Season 2
RSL Revival: Season 3
META Madness #9
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 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.