This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

C++: working with bits?

C++: working with bits?
by on (#29821)
I'm reading a 6502 programming book, and have decided to code every peice mentioned in the book, put it together and make it work.

so, i've got the boost libraries installed and am using 8 and 16 bit integer types. but i can't measure them( sizeof() only measures in bytes ) and i don't know how i can work with bits if i'm only measuring bytes.

anyone know of a solution to this?

#include <iostream>
#include <boost/cstdint.hpp>

using namespace std;

int main()
   static const boost::int8_t   int8;
   cout << "sizeof(int8) = " << sizeof(int8) << endl;
    return 0;

by on (#29822)
int8_t is a signed 8-bit integer. sizeof gives the size of an object, in bytes. sizeof (char) is defined to be 1. numeric_limits<type>::digits gives the number of bits in a type. But, why C++ for learning 6502?

by on (#29823)
blargg wrote:
But, why C++ for learning 6502?

I don't know about Laserbeak43's situation, but at least my own projects use custom tools written in C to build lookup tables and to convert assets (images, maps, sound) to NES-friendly formats.

by on (#29824)
Yeah, but he's learning, not building a game or anything...

by on (#29825)
blargg wrote:
But, why C++ for learning 6502?

- I have no clue too. ^_^;;

by on (#29826)
hehe, well it was my original idea to build the things that i read about the 6502 as i go along, but it it turns out that this rodnay zaks book is part 2 of a series of like seven books or something. and the actual book that has the actual tech info on the 6502 is the volume before this one... so i might not be able to do that and just concentrate on 6502 programming.

new thread coming in the newb section :)

by on (#29827)
Oh how I wish was still up...

by on (#29829)
atari2600a wrote:
Oh how I wish was still up...