Jump to content

  • Log In with Google      Sign In   
  • Create Account

TheComet

Member Since 02 Oct 2013
Offline Last Active Yesterday, 01:31 PM

Posts I've Made

In Topic: Rising sea's

09 December 2015 - 06:05 AM

You're also just flat-out wrong. If I encouraged 10 other people to "go green" but din't alter my own lifestyle one jot, that would have MORE impact.


That would only be true if you assume those 10 people actually take the advice and alter their lifestyle. Chances are they're just like you: They hear the advice but they don't do jack about it because they think they are too insignificant to make a change. In a situation like that, if you change your lifestyle, your actions DO have an impact. But these scenarios are completely irrelevant because of what I said earlier.

If you change, you make the same impact than if you don't do anything at all. That's my point.
 

My personal actions make NO difference to overall climate effects


Do you really believe that? Simple things like turning off lights when you don't need them, using low power light bulbs, not flushing the toilet unnecessarily, taking short showers, etc. These all have a larger impact than what you might expect.

In Topic: Why didn't somebody tell me?

08 December 2015 - 07:52 PM

Cats. They are not dogs.

1) Dogs have four legs
2) Cats have four legs
3) Therefore, cats are dogs.

Checkmate atheists.

In Topic: Rising sea's

08 December 2015 - 06:21 PM

I think you've rather missed the point here. We aren't discussing how many aircraft carriers China have.


I'll break down the analogies since it is you who is missing the point.

The argument against your original (ignorant) statement was that if a significant number of humans join the bandwaggon and actively start saving energy and start being more aware, it will have a significant impact on the environment.

Saying "what I do doesn't make a difference because I'm insignificant" is easily the most ignorant thing you could possibly say, ever. It's right up there with "I don't care if the NSA scans my files; I have nothing to hide" or "I don't care about freedom of speech; I have nothing to say".

What you do is precisely the only thing that can make a difference, because only you are in control of what you do. Having the attitude you have is unfortunately what most people's attitude is, which just further proves my point of joint effort (or in this case, lack thereof) being significant, because it may just be dooming us all.

In Topic: Question about type, and displaying the bits of a char

18 November 2015 - 07:32 PM

God damn it, I had a super long post typed up and chrome crashed because I hit CTRL+S.
 
You don't really see bitfields in desktop applications because there's no need to conserve memory. You'll find them in code that makes heavy use if bit masking (crypto?) or memory conservation (networking code?). I program micro controllers for my day job and we make heavy use of bitfields.

[EDIT] Just to be clear and as mentioned in the coming posts: This is not portable.
 
Here's an example. Imagine you had to pack a "move" instruction of a chess piece in a game of chess into as little space as possible. Reasons being you want to transmit the move over a network and save space. You could encode this by using a "to" and "from" coordinate. Seeing as a chess board is 8x8, a coordinate can be packed into 6 bits. You could write:
u16 move = 0;
move |= (current_x << 0);
move |= (current_y << 3);
move |= (new_x << 6);
move |= (new_y << 9);
/* 4 bits reserved for whatever */
Using bitfields makes this much more readable:
struct chess_move_t {
    union {
        struct {
            unsigned current_x : 3;
            unsigned current_y : 3;
            unsigned new_x : 3;
            unsigned new_y : 3;
            unsigned :4; /* unused */
        };
        u16 data;
    };
};
The following code does the same thing as the first example.
struct chess_move_t move;
move.current_x = current_x;
move.current_y = current_y;
move.new_x = new_x;
move.new_y = new_y;
 



Here's a real world example of some micro controller code, just in case you were wondering.
void timer_init(void)
{
    /*
     * Target interrupt frequency is 100Hz
     * 
     * Fcy = 7.37 * 65 / 8 = 59.88125 MHz
     * Prescale 1:64 ~ 936 kHz
     * Using 16-bit timer type B: count to 9356 for 100 Hz
     * 
     * We'll be using a timer type B, specifically timer 4, so we don't
     * clash with the timer required for ADC conversions.
     * 
     * Notes on config:
     *  + Clock source select by default is Fosc / 2
     *  + Default mode is 16-bit mode
     */
    T4CONbits.TON = 0;      /* disable timer during config */
    T4CONbits.TCKPS = 0x02; /* prescale 1:64 */
    PR4 = 9356;             /* period match, divide the 936 kHz by 9356 to 
                             * reach 10ms */
    IFS1bits.T4IF = 0;      /* clear interrupt flag */
    IEC1bits.T4IE = 1;      /* enable timer 4 interrupts */
    
    T4CONbits.TON = 1;      /* start timer */
}
The relevant bitfield declarations are the following (this is found in a header file provided by Microchip)
#define T4CON T4CON
extern volatile unsigned int  T4CON __attribute__((__sfr__));
__extension__ typedef struct tagT4CONBITS {
  union {
    struct {
      unsigned :1;
      unsigned TCS:1;
      unsigned :1;
      unsigned T32:1;
      unsigned TCKPS:2;
      unsigned TGATE:1;
      unsigned :6;
      unsigned TSIDL:1;
      unsigned :1;
      unsigned TON:1;
    };
    struct {
      unsigned :4;
      unsigned TCKPS0:1;
      unsigned TCKPS1:1;
    };
  };
} T4CONBITS;
extern volatile T4CONBITS T4CONbits __attribute__((__sfr__));

In Topic: How do you pronounce 'ptr'?

18 November 2015 - 05:22 AM

No, no, I make my games on a cmptr.

 

(side note)

Why does this thread keep saying it has new posts? Does voting in the poll actually bump?


PARTNERS