Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 82 83 [84] 85 86 ... 796

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

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1245 on: February 04, 2012, 01:32:06 am »

A double is 64 bits wide, a long double is 80 bits wide. What textbook are you using anyway?
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1246 on: February 04, 2012, 01:41:28 am »

This one.

And yeah, all it really says is that long double is bigger than double. No explanation of why you should use one or the other, or why numbers seem to approach infinity.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1247 on: February 04, 2012, 02:03:10 am »

Success! Finally!

It's probably longer than it truly needs to be, and I could combine all those final printf statements if I really felt like it, but I don't care!
Spoiler (click to show/hide)
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

Mictlantecuhtli

  • Bay Watcher
  • Grinning God of Death
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1248 on: February 04, 2012, 02:09:06 am »

I haven't bothered to read the past 84 pages, because I'm a lazy ass, but I've always been really interested in programming and the languages involved. So I figure I'm just going to jump head-first into this like I usually do and hope for the best. I have many, many, many questions, though.

Basically, I have the issue of not knowing what to pick when it comes to learning a language of programming. I'm a mathematician at heart, so persistance is on my side. I just don't know entirely what it comes down to to just pick up a language. I'm sure if I begin on a certain type I'd eventually switch if my experience turns out good enough. Does anyone have any recommendations where to begin? I'm not necessarily looking for the "noob" language, just one to build on. I would also love guides upon guides, as I don't care about reading.

I have a little background in html and older website coding, but that's all gone the way of the past as 90's websites looked absolutely terrible in comparison to the stuff Flash/Dreamweaver can do when in skilled hands. So I'm no stranger to having to learn a codex if need be.
Logged
I am surrounded by flesh and bone, I am a temple of living. Maybe I'll maybe my life away.

Santorum leaves a bad taste in my mouth,
Card-carrying Liberaltarian

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1249 on: February 04, 2012, 02:24:30 am »

Don't think anyone's posted it yet, the people who did the AI course on the internet are doing an introduction to programming class.

Looks interesting.
Reposting that in the free college resources thread.

And yeah, all it really says is that long double is bigger than double. No explanation of why you should use one or the other, or why numbers seem to approach infinity.
The difference is precision and memory cost. By definition, a variable can only hold as many bits and it takes up in size. Larger variables allow for more precision, while smaller allow you to use a smaller amount of memory. 'short' is typically an integer taking up 16 bits (2^16 = 65536 values, or -32768 to 32767 if signed), 'int' is typically an integer taking up 32 bits (2^32 = about 4.29 billion values, similar split down the middle if signed), then it gets into interesting territory. Floats, doubles, and the like have a few different part within their memory space. One part is some form of exponent, while the other are the digits; similar to the scientific notation used to write numbers when they are too long to care about the itty bitty parts. Thus, they have a much higher range of values, but have imprecision introduced as a result. In most cases, this imprecision is relatively unimportant, and so the trade-off is seen as acceptable. A double has twice the memory size of a float, and thus a much larger range and precision. Based on the cplusplus.com website, a float in C++ can represent values ranging from about 10^+-38 with a precision of about 7 decimal places; that's adequate for most uses, but there are cases in which more precision is needed, and so the 64 bit double can be used; it can represent values in the range of 10^+-308 with a precision of about 15 decimal places.
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #1250 on: February 04, 2012, 05:24:27 am »

Usually a float is a "single" as defined in IEEE 754, which is 32-bits.
Usually double is exactly what it says on the tin, two singles in size, 64 bits.
Usually a long double is some size bigger than a double. On GCC it is 80-bits I believe. Visual C++ just treats it as another double. This is why I say usually, the standard doesn't specify exact sizes or exact implementations so different compilers will do things differently.

The basic representation is the highest bit is the sign. You then have a series of exponent bits, followed by the fraction. 32-bit typically will have an exponent of 8-bits, and a fraction of 23 bits. 64-bit has 11 exponents and 52 fractions, hence the greater accuracy. Rounding errors can occur as not every number can be represented using this notation, like how we might have to simplify 1423.423543674574574564 to 1.4234e10^3. The more digits we can store in that representation, the closer to the true value we become.

You don't really ever need to worry about this until it bites you in the arse. Personally in C++ I'll always typedef the floats I'm using, that way if I ever encounter a problem with accuracy I can just change one line and see if that fixes things. You know how sometimes a physics simulation will just go crazy and explode? It's surprising how often that's due to a rounding error...

There are some things to be aware of in those situations, the main one being: Mixing very big and very small numbers together doesn't usually end well. 0.0000232342324 * 2423423524653 = omfgwtfisgoingonwhyiseverythingexploding? If you're doing this, revisit the scales and find some way to stop it. Fixing your timestep is always good. I personally have found it works well to ensure the timestep is always a multiple of a specific step, capping that multiple at a specific value and passing the remainder over to the next frame.
« Last Edit: February 04, 2012, 05:34:26 am by MorleyDev »
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1251 on: February 04, 2012, 07:38:20 am »

So I got through the second part of the tutorial, but the program keeps auto-closing instantly and returns -1.

After some commenting out I believe that this code here causes this:
Code: [Select]
if((Surf_Test = CSurface::OnLoad("tileset.bmp")) == NULL) {
        return false;
    }

Said NULL can only come from
Code: [Select]
SDL_Surface* CSurface::OnLoad(char* File) {
[...]
    if((Surf_Temp = SDL_LoadBMP(File)) == NULL) {
        return NULL;
    }
[...]
}
, meaning that most likely the program just doesn't find the BMP file.

MEEEEEH.
« Last Edit: February 04, 2012, 07:52:15 am by Darvi »
Logged

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1252 on: February 04, 2012, 07:49:38 am »

CSurface::OnDraw returns a bool. Why are you returning NULL?
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1253 on: February 04, 2012, 07:51:36 am »

... I'm not?

Oh wait. Fucking copypasta.
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #1254 on: February 04, 2012, 09:22:42 am »

NULL == 0 == false, it's something you see a lot of in C code, since C didn't originally have a "true or false" boolean operator. Nowadays it's defunct and kinda ugly but still crops up...
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1255 on: February 04, 2012, 09:49:42 am »

That's still not the problem because OnLoad doesn't have any bools.
Logged

Errol

  • Bay Watcher
  • Heaven or Hell, Duel 1 -- Let's Rock!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1256 on: February 04, 2012, 10:25:17 am »

Hey Errol, before I forget, you should change one of your lines to this
Code: [Select]
bi = ImageIO.read(new File(@"./img/tileclose.png"));

That just produces four syntax errors in which he basically complains that there is an @. You sure about this?

/edit: HAHAHA SUCCESS!!! Adrenaline stack overflow. The old new pathing code was indeed correct. I just forgot to add Screenfiller to the main panel, which I did now, and it's working like a charm.

Alright, hopefully the rest will be smooth cruising! Got some labyrinth logic to write.
« Last Edit: February 04, 2012, 10:29:50 am by Errol »
Logged
Girls are currently preparing signature, please wait warmly until it is ready.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1257 on: February 04, 2012, 10:31:35 am »

That is invalid in Java? I thought that was a thing Java did, and c# didn't... Maybe I got that the wrong way around and it is a c# thing.

Too many fucking languages.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1258 on: February 04, 2012, 01:26:02 pm »

http://www.cs.rit.edu/~ark/lectures/cuda01/
Notes from a talk about CUDA programming. For those who aren't familiar with the term, it's using the GPU to do processing; CUDA is Nvidia's version; though the ideas hold true for other cards using things like OpenCL (a more standardized version which works for all GPUs). Aside from the notes themselves, there's a bunch of links to other references at the bottom.

Worth a look if you care to learn more about how GPU processing works.
Logged

Darvi

  • Bay Watcher
  • <Cript> Darvi is my wifi.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1259 on: February 04, 2012, 02:22:14 pm »

I have verified that the .exe does indeed not find the graphic files. Gotta figure out why.
Logged
Pages: 1 ... 82 83 [84] 85 86 ... 796