Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 343 344 [345] 346 347 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 884705 times)

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5160 on: October 30, 2013, 01:49:01 am »

One of my Profs held that attitude and I couldn't finish the assignment because GCC couldn't parse the hackish code allowed by it.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #5161 on: October 30, 2013, 02:30:35 am »

Maybe you could have used MSVS... Just a thought >_>
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5162 on: October 30, 2013, 04:23:35 am »

I could have, but why should I have to download MSVS when I had GCC already set up and had completed the earlier assignments with it? It wasn't a MSVS course, it was a C++ and data structures course. Is standard compliant code too much to ask for in an academic environment?
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5163 on: October 30, 2013, 09:35:33 am »

I'm now curious what the assignment must have been, because I can't imagine using compiler specific extensions or hacks in such a course.  That really does sound like bad form.

I will stand by using Visual Studio for its debugger though.  Back when I took a similar course, I compiled assignments in it more than once just so I could use its debugger, even though we were required to build the final executable in a Linux environment.
Logged
Through pain, I find wisdom.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5164 on: October 31, 2013, 02:22:16 am »

Fun fact: our illustrious leader, Toady One, uses MSVC for the debugger.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5165 on: October 31, 2013, 03:27:39 am »

My first Open Source Project. I just wrote the web-part, though. It's also not very clean, and if you haven't worked with Yii, probably won't make much sense.
If you try to install it, be careful as, IIRC, you can make it into a debian package installer, but that one is destructive to existing apache settings (I did not make that part), it's supposed to run in a dedicated VPS.

https://greenhost.io/projects/uman/

So yeah, probably not that interesting to anyone here, but still, a milestone of its own for me :)
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

zombie urist

  • Bay Watcher
  • [NOT_LIVING]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5166 on: November 02, 2013, 02:46:17 pm »

C++
Code: [Select]
float t = 1.0/10.0; //t = 0.1
int i = 1 / t;      //i = 9?
float f = 1 / t;    //f = 10.0
int if = f;         //if = 10?
Anyone know why?
Logged
The worst part of all of this is that Shakerag won.

eerr

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5167 on: November 02, 2013, 03:16:03 pm »

Add like .000001 or something before rounding to (INT)

It's either marginally above or below 0.1 in floating Point.
You just got rounded down
Logged

Mini

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5168 on: November 02, 2013, 03:45:44 pm »

Actually, you can just use this function. But yes, floating point error means that casting directly to int (or comparing equals to without some sort of margin for error will very likely not give you the result you expected.
Logged

cerapa

  • Bay Watcher
  • It wont bite....unless you are the sun.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5169 on: November 02, 2013, 03:59:47 pm »

C++
Code: [Select]
float t = 1.0/10.0; //t = 0.1
int i = 1 / t;      //i = 9?
float f = 1 / t;    //f = 10.0
int if = f;         //if = 10?
Anyone know why?
Dis some testing of my own

Code: [Select]
float t = 1.0/10.0; //t = 0.1
int i = 1 / t;      //i = 9
float f = 1 / t;    //f = 10
int if = f;         //if = 10
double d = 1 / t; // d = 10
int id = d; // id = 9 (wtf)

Might be doing division as doubles and then...fucking up gloriously.
Logged

Tick, tick, tick the time goes by,
tick, tick, tick the clock blows up.

miauw62

  • Bay Watcher
  • Every time you get ahead / it's just another hit
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5170 on: November 02, 2013, 04:16:23 pm »

Floats are an incarnation of Satan.
Logged

Quote from: NW_Kohaku
they wouldn't be able to tell the difference between the raving confessions of a mass murdering cannibal from a recipe to bake a pie.
Knowing Belgium, everyone will vote for themselves out of mistrust for anyone else, and some kind of weird direct democracy coalition will need to be formed from 11 million or so individuals.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #5171 on: November 02, 2013, 09:51:55 pm »

Very convenient incarnations of Satan.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

ECrownofFire

  • Bay Watcher
  • Resident Dragoness
    • View Profile
    • ECrownofFire
Re: if self.isCoder(): post() #Programming Thread
« Reply #5172 on: November 02, 2013, 10:06:12 pm »

Just never cast them to integer types and you're fine. There's a reason rounding functions exist.

Also don't test for equality with them. Sadly there's no clean solution for this except just not doing it.
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #5173 on: November 03, 2013, 11:49:00 am »

1 / d is probably being stored as something like 9.99999999991321254125 because rounding errors. Casting to an int always floors the value, and thus 9.
« Last Edit: November 03, 2013, 12:28:39 pm by MorleyDev »
Logged

Lightningfalcon

  • Bay Watcher
  • Target locked. Firing main cannon.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #5174 on: November 03, 2013, 01:49:52 pm »

Can someone help me with  this?  We had to make a Queue for a hospital waiting list in Computer Science.  He gave us the code for making a queue, and it worked for most of the class so that part should work. 
Spoiler (click to show/hide)

Spoiler (click to show/hide)

I checked the Queue code and it's the exact same as the person next to me, and enque is set up the same as the guy next to me.    The error I'm getting is "Cannot find symbol" on
patients.enque(priority, name);
Logged
Interdum feror cupidine partium magnarum circo vincendarum
W-we just... wanted our...
Actually most of the people here explicitly wanted chaos and tragedy. So. Uh.
Pages: 1 ... 343 344 [345] 346 347 ... 796