Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 89 90 [91] 92 93 ... 796

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

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1350 on: February 08, 2012, 01:24:22 am »

That is pretty bizarre.  I'm not sure about C#, but in C or C++ I'd wager you're multiplying an int by a double, when you need to cast the int to a double before multiplying.  Otherwise, some compilers at least will do integer multiplication there.  That might even be part of the standard somewhere, I don't know.

Regardless though, I have no idea how it would get 8 out of that.
Logged
Through pain, I find wisdom.

RulerOfNothing

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1351 on: February 08, 2012, 01:38:01 am »

That is pretty bizarre.  I'm not sure about C#, but in C or C++ I'd wager you're multiplying an int by a double, when you need to cast the int to a double before multiplying.  Otherwise, some compilers at least will do integer multiplication there.  That might even be part of the standard somewhere, I don't know.

Regardless though, I have no idea how it would get 8 out of that.
Which compiler does integer multiplication in that case? I am pretty sure the C++ standard calls for integers to be implicitly converted when they are part of an expression containing floating-point types (hence the common technique of forcing one of the operands in a division operation to be a float to avoid using integer division).
Logged

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1352 on: February 08, 2012, 01:44:50 am »

I don't think c# is subject to it unless you are only using integers, and in that case multiplication should not pose a problem. Division, however, is pretty much a universal problem for ints.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1353 on: February 08, 2012, 01:53:20 am »

@Fayrik:
Depending on how small your game is, you may well end up needing to use such graphics libraries. Texture copying to a buffer is extremely slow. For one, you are running it on the CPU; two, the GPU hardware is specially optimized for rendering graphics to the screen. Pretty much all 2D games these days go through roughly the same graphics pipeline in hardware as a 3D game would, though the level of encapsulation of that functionality by libraries varies. It is not only more efficient, but makes some otherwise nearly impossible tasks possible. In a bitmap copy based system, you are pretty much screwed if you decide you want to rotate a texture; for a proper rendering system, it is calculated automatically with pretty much 0 additional cost. You may consider 40 fps to be good, but for a 2D game, especially if you don't have all your graphical content in yet, it's getting really low. Depending on how much more you need to add, you may be forced to use a graphics library to get an acceptable framerate.
Logged

Heron TSG

  • Bay Watcher
  • The Seal Goddess
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1354 on: February 08, 2012, 02:03:58 am »

Spoiler: Does this count? (click to show/hide)

Decided to learn how to make, design, and construct a 16-bit ALU for my Senior Project. This right here is a 1-bit ALU. I'll just need to staple 16 of them together (closer than you might think) and I'm set. It'll be manual-switch controlled, and you'll have to read the output binary from the LEDs.

I'm hoping that if I can string enough of these together, I can build something powerful enough to write a program for. (Even if it's just a very simple input-output algorithm.)
Logged

Est Sularus Oth Mithas
The Artist Formerly Known as Barbarossa TSG

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1355 on: February 08, 2012, 02:12:28 am »

Spoiler: Does this count? (click to show/hide)

Decided to learn how to make, design, and construct a 16-bit ALU for my Senior Project. This right here is a 1-bit ALU. I'll just need to staple 16 of them together (closer than you might think) and I'm set. It'll be manual-switch controlled, and you'll have to read the output binary from the LEDs.

I'm hoping that if I can string enough of these together, I can build something powerful enough to write a program for. (Even if it's just a very simple input-output algorithm.)
Got a present for you.  http://ozark.hendrix.edu/~burch/logisim/
Logisim; a program we are using in one of my classes to simulate just such things. It's got a variety of different levels of parts, ranging from simple logic operators up to a variety of standardized components used to create computers.
« Last Edit: February 08, 2012, 02:15:25 am by alway »
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1356 on: February 08, 2012, 08:38:37 am »

That is pretty bizarre.  I'm not sure about C#, but in C or C++ I'd wager you're multiplying an int by a double, when you need to cast the int to a double before multiplying.  Otherwise, some compilers at least will do integer multiplication there.  That might even be part of the standard somewhere, I don't know.

Regardless though, I have no idea how it would get 8 out of that.
Which compiler does integer multiplication in that case? I am pretty sure the C++ standard calls for integers to be implicitly converted when they are part of an expression containing floating-point types (hence the common technique of forcing one of the operands in a division operation to be a float to avoid using integer division).

I could have sworn GCC did this.  On the other hand, I think perhaps I was misremembering and thought you had to cast all operands to floating point types to get floating point math.  Apparently it was just one operand.  I don't write a whole lot of C or C++ these days.
Logged
Through pain, I find wisdom.

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1357 on: February 08, 2012, 01:59:34 pm »

So, the question. Is writing then destroying large sums of memory dangerous? Or, more fittingly, how dangerous is it?
Not dangerous, but reallocating that often can be slow... Can't you just re-use the space?
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))

MadocComadrin

  • Bay Watcher
  • A mysterious laboratory goblin!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1358 on: February 08, 2012, 02:02:48 pm »

Got a present for you.  http://ozark.hendrix.edu/~burch/logisim/
Logisim; a program we are using in one of my classes to simulate just such things. It's got a variety of different levels of parts, ranging from simple logic operators up to a variety of standardized components used to create computers.
I <3 Logisim. I used it for a class project more than once (but I had to then take the work and copy it over to TKGate). It would be perfect if it had pull-up and pull-down transistors, though.
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #1359 on: February 08, 2012, 02:46:31 pm »

I have to make an 8-bit ALU for my coursework. Thinking of doing it in Minecraft too just for kicks, might make a series going through how to do so step by step...
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1360 on: February 08, 2012, 07:54:34 pm »

I have to make an 8-bit ALU for my coursework. Thinking of doing it in Minecraft too just for kicks, might make a series going through how to do so step by step...
Considering the minecraft wiki has a diagram of various logic components, it's not all that hard. Though some of the components on there are poorly designed, as they're all pre-repeater tech. PLAs are really easy to implement in minecraft too.
Logged

lordnincompoop

  • Bay Watcher
  • Allusionist
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1361 on: February 08, 2012, 08:07:21 pm »

Now for a C++ question - I'm doing some floating point arithmetic, and though I've got that down I'm straining against the accuracy limitations inherent in floating points. I don't suppose there's an alternative available that can provide variables and/or mathematical functions (preferably including trigonometric ones) that provide full accuracy insomuch as that is possible on a computer?

I'd just like the results from this to be as accurate as the values I get from pushing through the same equation manually through WolframAlpha - maybe that's an unreasonable request, but I can dream, can I not?


I have to make an 8-bit ALU for my coursework. Thinking of doing it in Minecraft too just for kicks, might make a series going through how to do so step by step...

I'd, uh, advise against it, especially when taking into the difficulty and added time of making redstone logic gates manually and synchronising torch delay times in so unstable and slow a "computing engine" as Minecraft, while at the same time making sure that you have no logic in an unloaded chunk.
Logged

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1362 on: February 08, 2012, 08:28:20 pm »

Now for a C++ question - I'm doing some floating point arithmetic, and though I've got that down I'm straining against the accuracy limitations inherent in floating points. I don't suppose there's an alternative available that can provide variables and/or mathematical functions (preferably including trigonometric ones) that provide full accuracy insomuch as that is possible on a computer?
Maybe something like this?
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1363 on: February 08, 2012, 08:31:03 pm »

Now for a C++ question - I'm doing some floating point arithmetic, and though I've got that down I'm straining against the accuracy limitations inherent in floating points. I don't suppose there's an alternative available that can provide variables and/or mathematical functions (preferably including trigonometric ones) that provide full accuracy insomuch as that is possible on a computer?

I'd just like the results from this to be as accurate as the values I get from pushing through the same equation manually through WolframAlpha - maybe that's an unreasonable request, but I can dream, can I not?

GMP, the GNU Multiple Precision library. It's a C library, but backwards-compatibility means that C++ can still use it. Just include the header like so to ensure proper linking:

Code: [Select]
#ifdef __cplusplus
extern 'C' {
#endif
#include <gmp.h>
#ifdef __cplusplus
}
#endif

http://gmplib.org/

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #1364 on: February 08, 2012, 11:16:30 pm »

Fukin user-defined functions, how do they work?
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
Pages: 1 ... 89 90 [91] 92 93 ... 796