• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 14:18
CET 19:18
KST 03:18
  • 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
[ASL20] Finals Preview: Arrival12TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9
Community News
BSL21 Open Qualifiers Week & CONFIRM PARTICIPATION1Crank Gathers Season 2: SC II Pro Teams6Merivale 8 Open - LAN - Stellar Fest3Chinese SC2 server to reopen; live all-star event in Hangzhou22Weekly Cups (Oct 13-19): Clem Goes for Four3
StarCraft 2
General
Could we add "Avoid Matchup" Feature for rankgame RotterdaM "Serral is the GOAT, and it's not close" Smart servos says it affects liberators as well Chinese SC2 server to reopen; live all-star event in Hangzhou The New Patch Killed Mech!
Tourneys
Crank Gathers Season 2: SC II Pro Teams RSL Offline Finals Dates + Ticket Sales! Merivale 8 Open - LAN - Stellar Fest $5,000+ WardiTV 2025 Championship $3,500 WardiTV Korean Royale S4
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment
Brood War
General
[ASL20] Finals Preview: Arrival BSL Season 21 BSL Team A vs Koreans - Sat-Sun 16:00 CET ASL20 Pre-season Tier List ranking! ASL Runner-Up Race Stats
Tourneys
[ASL20] Grand Finals BSL21 Open Qualifiers Week & CONFIRM PARTICIPATION ASL final tickets help [ASL20] Semifinal A
Strategy
Current Meta Soma's 9 hatch build from ASL Game 2 Simple Questions, Simple Answers Roaring Currents ASL final
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile General RTS Discussion Thread Nintendo Switch Thread Dawn of War IV
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
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread YouTube Thread The Chess Thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Korean Music Discussion Series you have seen recently... Movie Discussion!
Sports
Formula 1 Discussion 2024 - 2026 Football Thread MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 NBA General Discussion
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 Benefits Of Limited Comm…
TrAiDoS
Sabrina was soooo lame on S…
Peanutsc
Our Last Hope in th…
KrillinFromwales
Certified Crazy
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1587 users

The Big Programming Thread - Page 670

Forum Index > General Forum
Post a Reply
Prev 1 668 669 670 671 672 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.
Manit0u
Profile Blog Joined August 2004
Poland17399 Posts
Last Edited: 2015-10-19 15:17:52
October 19 2015 15:16 GMT
#13381

$str = explode(' ', $attributes);

foreach ($str as $string) {
if (strstr($string, 'something')) {
$service = explode('something', $string);
}
}

return substr($service[1], 0, -1);


I just love it when people write self-documenting code... It strikes the right strings.
Time is precious. Waste it wisely.
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2015-10-20 18:40:22
October 20 2015 18:39 GMT
#13382
So it just so happens I'm taking a microcontroller class this quarter using AVR and our professor had code that counted using a modulo operator like so:


if((count % 64) == 0) {
//do something
}

His reasoning for this was so that you could avoid resetting the counter back to 0 every time the loop executes. Is that right? You lose one line of code but you end up using modulo which is probably a super expensive computation in comparison to a simple equality check and reset.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
October 20 2015 19:08 GMT
#13383
On October 21 2015 03:39 Itsmedudeman wrote:
So it just so happens I'm taking a microcontroller class this quarter using AVR and our professor had code that counted using a modulo operator like so:


if((count % 64) == 0) {
//do something
}

His reasoning for this was so that you could avoid resetting the counter back to 0 every time the loop executes. Is that right? You lose one line of code but you end up using modulo which is probably a super expensive computation in comparison to a simple equality check and reset.

Your compiler will (or at least should) turn a modulo of a (constant) power of 2 into a simple bitmask, which should be a lot faster than a conditional jump. In the general case modulo is slow though.

I suppose at microcontroller level this stuff might actually be relevant, but always remember that you should profile before you do something in the name of performance.
If you have a good reason to disagree with the above, please tell me. Thank you.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-10-21 01:15:49
October 21 2015 01:15 GMT
#13384
Basically my last week at work has been profiling stupid Bluetooth code, fml and f Bluetooth. The word profiling causes physical pain to me.



Going to take the hardest programming class at my university next term, real-time os or "trains" as we call it. A lot of embedded C :3 any tips for preparation? I feel like I should write some C utility libraries for linked lists and queues and unit tests.
There is no one like you in the universe.
MysteryMeat1
Profile Blog Joined June 2011
United States3292 Posts
Last Edited: 2015-10-21 07:43:30
October 21 2015 07:19 GMT
#13385
I had a quick jquery question. I'm making my table and i'm appending rows and stuff.

$('.table').append("<tr><td>Non-white</td><td>'nMen'</td><td>'nWomen'</td><</tr>'");

nMen and nWomen are both variables but I dont know how to reference them so they show up as numbers and not as nMen and nWomen in the cell.

EDIT: Solved my own question
"Cause ya know, Style before victory." -The greatest mafia player alive
windzor
Profile Joined October 2010
Denmark1013 Posts
October 21 2015 07:23 GMT
#13386
On October 21 2015 03:39 Itsmedudeman wrote:
So it just so happens I'm taking a microcontroller class this quarter using AVR and our professor had code that counted using a modulo operator like so:


if((count % 64) == 0) {
//do something
}

His reasoning for this was so that you could avoid resetting the counter back to 0 every time the loop executes. Is that right? You lose one line of code but you end up using modulo which is probably a super expensive computation in comparison to a simple equality check and reset.


It's properly a general rule he learned on a platform which had this feature. It might not be true in the general case.

In microcontrollers you sometimes do weird things. Today on several highly used platforms you should stay far away from switch statements and just use else if statements. It saves 40% power... Which is absurd to wrap ones head around but if you do a controlled test where you measure the used battery usage you will see that it is real..
Yeah
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
October 21 2015 15:19 GMT
#13387
On October 21 2015 16:23 windzor wrote:
In microcontrollers you sometimes do weird things. Today on several highly used platforms you should stay far away from switch statements and just use else if statements. It saves 40% power... Which is absurd to wrap ones head around but if you do a controlled test where you measure the used battery usage you will see that it is real..


Why? Compiler bugs or something?
Manit0u
Profile Blog Joined August 2004
Poland17399 Posts
Last Edited: 2015-10-21 15:45:59
October 21 2015 15:44 GMT
#13388
On October 22 2015 00:19 netherh wrote:
Show nested quote +
On October 21 2015 16:23 windzor wrote:
In microcontrollers you sometimes do weird things. Today on several highly used platforms you should stay far away from switch statements and just use else if statements. It saves 40% power... Which is absurd to wrap ones head around but if you do a controlled test where you measure the used battery usage you will see that it is real..


Why? Compiler bugs or something?


I guess it depends on the language (for microcontrollers it'll most likely be C) and its switch statement implementation.

Anyway, I don't think there should be that much difference. The compiler should turn if/elseif ladders into switches (jump tables) and vice versa if that would work better.

Here's some interesting reading on it (albeit a bit dated): http://embeddedgurus.com/stack-overflow/2010/04/efficient-c-tip-12-be-wary-of-switch-statements/

It seems that with switch statements you get good average performance but its best performance is worse than if-else and you can't optimize it (like you can if-else by evaluating the most common thing first).
Time is precious. Waste it wisely.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
October 23 2015 05:53 GMT
#13389
http://kamalmarhubi.com/blog/2015/09/15/eliminating-branches-in-rust-for-fun-but-not-much-profit/

^ this is super cool btw
There is no one like you in the universe.
Thaniri
Profile Blog Joined March 2011
1264 Posts
October 23 2015 19:29 GMT
#13390
+ Show Spoiler +

private void buttonStart_Click(object sender, EventArgs e)
{
int principal = 1000;
double rate = 0.05;
int count = 1;

while (count <= 5){
string someString = (Math.Round(principal * (Math.Pow(1 + rate, count)))).ToString();
listBoxOutputs.Items.Add(someString);
count = count + 1;
}
}


This is C#, how do I apply Math.Round() here to have 2 points after the decimal?

Google tells me that it should work like
a=1.333
Math.Round(a,2) = 1.33

In my example, where do I put that 2?
raNazUra
Profile Joined December 2012
United States10 Posts
October 23 2015 19:54 GMT
#13391
On October 24 2015 04:29 Thaniri wrote:
+ Show Spoiler +

private void buttonStart_Click(object sender, EventArgs e)
{
int principal = 1000;
double rate = 0.05;
int count = 1;

while (count <= 5){
string someString = (Math.Round(principal * (Math.Pow(1 + rate, count)))).ToString();
listBoxOutputs.Items.Add(someString);
count = count + 1;
}
}


This is C#, how do I apply Math.Round() here to have 2 points after the decimal?

Google tells me that it should work like
a=1.333
Math.Round(a,2) = 1.33

In my example, where do I put that 2?


Assuming your explanation is correct (don't have C# running on my machine to verify this), you'll want a ", 2" after the second close paren on that line. Something like this:


string someString = (Math.Round(principal * (Math.Pow(1 + rate, count)), 2)).ToString();


It's exactly the same as the example, except a is replaced with some expression whose value you're interested in printing.
Speak the truth, even if your voice shakes
Thaniri
Profile Blog Joined March 2011
1264 Posts
October 23 2015 21:00 GMT
#13392
It works, I have no idea why the 2 would be there and not one parenth left.
Prillan
Profile Joined August 2011
Sweden350 Posts
October 23 2015 21:17 GMT
#13393
On October 24 2015 06:00 Thaniri wrote:
It works, I have no idea why the 2 would be there and not one parenth left.

var a = principal * Math.Pow(1 + rate, count);
string someString = Math.Round(a, 2).ToString();


Is it clearer now?
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
Thaniri
Profile Blog Joined March 2011
1264 Posts
October 23 2015 21:27 GMT
#13394
Ah the separation helped a lot, thank-you to both of you.
Wrath
Profile Blog Joined July 2014
3174 Posts
October 24 2015 08:35 GMT
#13395
Hello everyone. Thank you OP for making this thread and sharing the other posts on the first post about learning C first and stuff. I'd like to participate in this thread and learn more about programming. My issue is not learning the language as syntax or how things work in the stack or windows API or other stuff, but not finding anything to practice this learning process on. My imagination is closer to -9000. So I can't really come up with some ideas to make software and practice my learning on it.

My work field as an administrator does not give me problems to be solved by using stuff like "memory optimizing" and other stuff I'd like to see like testing performance on certain programs.

I'd love if anyone can point me where I can find "ideas" on programs to develop even if they were already developed. The goal here is not commercial to sell. But a practice area, out of college homeworks and projects. I never got anything to practice my knowledge on.

Thanks.
tofucake
Profile Blog Joined October 2009
Hyrule19149 Posts
October 24 2015 13:25 GMT
#13396
What I do is find something that I use and try to copy it. Battle.net bots are where I started, but anything will do really: IRC clients, websites, basic games (connect four or something), whatever.
Liquipediaasante sana squash banana
Acrofales
Profile Joined August 2010
Spain18100 Posts
October 24 2015 14:02 GMT
#13397
My girlfriend expressed an interest in learning to code (from absolutele zero), so I pointed her towards codecombat.com as a fun way to start. It is aimed at kids, but it looks pretty decent. Opinions?
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
October 24 2015 16:01 GMT
#13398
--- Nuked ---
Wrath
Profile Blog Joined July 2014
3174 Posts
October 24 2015 17:55 GMT
#13399
On October 25 2015 01:01 Nesserev wrote:
Show nested quote +
On October 24 2015 17:35 WrathSCII wrote:
Hello everyone. Thank you OP for making this thread and sharing the other posts on the first post about learning C first and stuff. I'd like to participate in this thread and learn more about programming. My issue is not learning the language as syntax or how things work in the stack or windows API or other stuff, but not finding anything to practice this learning process on. My imagination is closer to -9000. So I can't really come up with some ideas to make software and practice my learning on it.

My work field as an administrator does not give me problems to be solved by using stuff like "memory optimizing" and other stuff I'd like to see like testing performance on certain programs.

I'd love if anyone can point me where I can find "ideas" on programs to develop even if they were already developed. The goal here is not commercial to sell. But a practice area, out of college homeworks and projects. I never got anything to practice my knowledge on.

Thanks.

Well, there's always Project Euler if small coding problems interests you:
https://projecteuler.net/

If you're interested in larger projects, you could do the following:
- When you use particular libraries, but find that they could be improved or they're not being supported/maintained anymore, feel free to contact the author(s) of that library and reach out a hand.

- Have you ever joined an AI contest, or any type of coding contest? Do you have a personal website with portfolio projects? Interested in pentesting and hacking?

- Also, maybe you can't think of anything to do, because your knowledge or field of attention is limited to certain areas. It might be a good idea to delve into fields that you've never delved into...


Thank you very much for sharing about projecteuler. I'll definitely check it out!
For now I'm only interested in smaller projects to strength my knowledge in the language and in certain parts of "things" like optimizing memory and strengthening my thinking and develop some background on things.

I have interest in emulator projects. I tried to get into one of them and talked with some of the developers there. They were really nice guys and willing to help. But the gap was just way too huge for me to fit in. I had to ask for many many things and I did not like that, even if they were always willing to answer any question no matter how trivial it was, I just couldn't keep asking.

It was not a syntax issue. It was more of a background issue on many topics like graphics / memory / system calls / and many other things that I have absolutely 0 knowledge about. So small projects that have defined goals would be the best for me.

About your questions, I never joined an AI contest or any type of coding contest before nor I have a website and I have no projects I have worked on. For now I need to "practice" my knowledge and upgrade it with experience. Since I have nearly zero experience(Who am I kidding I literally have zero experience). I need to work on that, for now, small projects would be perfect for me.

Although I am interested pentesting and hacking, it is still way too early for someone with my current experience

Thank you again for replying to my post!

Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2015-10-24 18:10:22
October 24 2015 18:10 GMT
#13400
My tip would be don't be afraid to try and take on something a bit bigger than something you think you can handle. If you only do practice problems that you already know all that teaches you is memorization skills. When you work on a harder project you can learn so much more by being forced to branch out of your comfort zone and learn things you can't learn from a textbook by encountering your own unique problems and problem solving your way through them with whatever resource available.
Prev 1 668 669 670 671 672 1032 Next
Please log in or register to reply.
Live Events Refresh
Monday Night Weeklies
17:00
Open Cup
RotterdaM543
TKL 310
IndyStarCraft 228
SteadfastSC196
ZombieGrub93
BRAT_OK 62
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 543
mouzHeroMarine 459
TKL 310
IndyStarCraft 228
SteadfastSC 196
UpATreeSC 100
ZombieGrub93
ProTech84
MaxPax 74
BRAT_OK 62
MindelVK 28
StarCraft: Brood War
Britney 21552
Sea 638
Yoon 363
Rock 54
Dewaltoss 37
yabsab 20
Dota 2
qojqva4220
Dendi1196
BananaSlamJamma252
PGG 89
Counter-Strike
fl0m2522
ScreaM1151
FunKaTv 64
Other Games
FrodaN1616
Beastyqt562
ceh9443
Lowko291
Liquid`VortiX219
mouzStarbuck210
B2W.Neo153
ArmadaUGS124
C9.Mang079
Mew2King74
QueenE62
rGuardiaN44
Organizations
Counter-Strike
PGL11530
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 22 non-featured ]
StarCraft 2
• kabyraGe 105
• iHatsuTV 6
• Reevou 2
• Kozan
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
• IndyKCrew
StarCraft: Brood War
• HerbMon 41
• FirePhoenix10
• Michael_bg 4
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 2788
League of Legends
• Nemesis3464
• imaqtpie1977
• TFBlade833
Other Games
• WagamamaTV415
• Shiphtur103
Upcoming Events
BSL 21
6h 42m
Replay Cast
15h 42m
Streamerzone vs Shopify Rebellion
Streamerzone vs Team Vitality
Shopify Rebellion vs Team Vitality
WardiTV Invitational
17h 42m
CrankTV Team League
18h 42m
BASILISK vs TBD
Team Liquid vs Team Falcon
BSL 21
1d 6h
Replay Cast
1d 15h
BASILISK vs TBD
Team Liquid vs Team Falcon
OSC
1d 17h
CrankTV Team League
1d 18h
Replay Cast
2 days
The PondCast
2 days
[ Show More ]
CrankTV Team League
2 days
Replay Cast
3 days
WardiTV Invitational
3 days
CrankTV Team League
3 days
Replay Cast
4 days
BSL Team A[vengers]
4 days
Dewalt vs Shine
UltrA vs ZeLoT
BSL 21
5 days
Sparkling Tuna Cup
5 days
BSL Team A[vengers]
5 days
Cross vs Motive
Sziky vs HiyA
BSL 21
6 days
Wardi Open
6 days
Liquipedia Results

Completed

ASL Season 20
WardiTV TLMC #15
Eternal Conflict S1

Ongoing

BSL 21 Points
CSL 2025 AUTUMN (S18)
BSL 21 Team A
C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
CranK Gathers Season 2: SC II Pro Teams
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
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025

Upcoming

SC4ALL: Brood War
YSL S2
BSL Season 21
SLON Tour Season 2
BSL 21 Non-Korean Championship
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
META Madness #9
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 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...

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.