Difference Between 32 bit and 64 bit operating system

We often come across the 32 bit and 64 bit operating systems in the computer world. Let us see the difference between those two.

What is 32bit and 64 bit?

32bit and 64 bit are the term whis is used to mention the bytes of data which can be processed by the RAM from processor in a single time. Simply we can say 32 bit OS means A processor can Read/Write 2^32 of bytes of data in RAM for a single machine cycle. and 64 bit OS means A processor can Read/Write 2^64 of bytes of data in RAM for a single machine cycle.

Let us go in deep

2^32 =   4294967296

So a 32 bit OS suits up to 4GB RAM, Using more than 4GB RAM for 32bit OS is useless and it will act as 4GB RAM only.

2^64 = 18446744073709551616

Yes a big number, 64 bit OS can be used for 16 exabyte of RAM. But this 16 exabyte is not for all it depends on the OS and processor.

Now a days all the OS and processors are upgrading to 64 bit only so the next think about the bit of OS processor and RAM before choosing it.

Cheers!!!!
-> Let Us Embed <-

This expression uses old style casts - How to avoid??

In C/C++ we often use a regular type of type casting i.e (expected_type) value.

This type of type casting is applicable in C only. You can use the same type in C++ also but it will show a warning This expression uses old style casts. If you want to over come this warning you need to use the new style of type casting and this is applicable only in C++. Let us see how can we over come this warning.!

New style of type casting

The new style of type casting comes with 4 types, they are

  1. static_cast
  2. dynamic_cast
  3. const_cast
  4. reinterpret_cast

1.static_cast

It is used as a simple type of cast which we often use (implicit conversion), byte to word, int to float, etc.
static_cast<float>(variable_name)

2.dynamic_cast 

It works only when source type is polymorphism. We can type cast any pointer or reference to any polymorphism type, also we can say it converts a pointer or reference within a hierarchy
dynamic_cast<expected_type *>(Source_Var_Name)

3.const_cast

You can use this when you want to strips away the const requirement.

4. reinterpret_cast

It is used when low level reinterpreting a bit pattern. It should be used with a bit pattern alignment order caution in your mind.

This is how you can overcome the warning "This expression uses old style casts"


Cheers!!!!
-> Let Us Embed <-

How to Set/Clear/Toggle multiple bit using C/C++

You may need to Set /Clear/Toggle multiple bit using C/C++ in your application. Let us see how we can achieve this in this tutorial.
Refer this before going down
Formula
Register_Value = Register_Value | (1<<X)
Register_Value = Register_Value & (~(1<<X))
Register_Value = Register_Value ^ (1<<X)
In all the listed formula above has common thing as 1<<X
here X is the position of the bit you want to set/clear/toggle
and 1 means binary one that is 1 bit

If you want to select two bit use 3<<X
3 in binary is 11

Cheers!!!!
-> Let Us Embed <-

Embedded interview questions - In general embedded - Part 2

1)How to achieve quadrature encoder in Software?
http://letusembed.blogspot.com/2015/11/quadrature-encoder-in-c-quadrature.html

2)Differentiate Prescalar and Postscalar or what is prescalar and postscalar
http://letusembed.blogspot.com/2015/11/what-is-prescalar-and-postscalar.html

3)How to check a particular bit in a register is set or not using C?
http://letusembed.blogspot.com/2015/08/how-to-check-bit-is-set-or-not-in.html

4)How to set a particular bit using C?
http://letusembed.blogspot.com/2015/12/how-to-set-clear-and-toggling.html

5)How to clear a particular bit in C?
http://letusembed.blogspot.com/2015/12/how-to-set-clear-and-toggling.html

6)How to toggle a particular bit in C?
http://letusembed.blogspot.com/2015/12/how-to-set-clear-and-toggling.html

7)How to set/Clear/Toggle multiple bit using C/C++?
How to set/clear/toggle multiple bit?

8)How to avoid This expression uses old style of cast?
http://letusembed.blogspot.com/2015/12/this-expression-uses-old-style-casts.html

9)What is a new style of cast?
http://letusembed.blogspot.com/2015/12/this-expression-uses-old-style-casts.html

10) Difference between 32 bit and 64 bit OS and Processors?
http://letusembed.blogspot.com/2015/12/difference-between-32-bit-and-64-bit.html

11)What is the Maximum limit of RAM you can choose for 32bit processor?
http://letusembed.blogspot.com/2015/12/difference-between-32-bit-and-64-bit.html

12)What is the Maximum limit of RAM you can choose for 64 bit processor?
http://letusembed.blogspot.com/2015/12/difference-between-32-bit-and-64-bit.html

Cheers!!!
-> Let us Emebed -<-

How to Set, Clear and toggling a particular bit in C, C++

In embedded world you may be need to set a particular bit while configuring a register, clear a bit when decoding a data and then toggle a bit in applications like external watchdog timer services. In this tutorial let us see how can we achieve this with C/C++ language.

Setting a particular bit

Bit wise OR (|) is used for setting a bit

Formula

Register_Value = Register_Value | (1<<X)
here, X is the position of the bit which you want to set.
Example
Consider a register with 1 byte of size.
It has value of 11010001, If i want to set the 2nd bit in this register
Register_Value = 11010001 | (1<<2)
Register_Value = 11010001 | 00000100
Register_Value = 11010101

Clearing a particular bit

Bit wise AND(&) is used for clearing a bit

Formula

Register_Value = Register_Value & (~(1<<X))
here, X is the position of the bit which you want to clear.
Example
Consider a register with 1 byte of size.
It has value of 11010101, If i want to set the 2nd bit in this register
Register_Value = 11010101 & (~(1<<2))
Register_Value = 11010101 & (~00000100)
Register_Value = 11010101 & 11111011
Register_Value = 11010001

Toggling a particular bit

Bit wise XOR(^) is used for toggling a bit

Formula

Register_Value = Register_Value ^ (1<<X)
here, X is the position of the bit which you want to toggle.
Example
Consider a register with 1 byte of size.
It has value of 11010101, If i want to toggle the 2nd bit in this register
Register_Value = 11010101 ^ (1<<2)
Register_Value = 11010101 ^ 000000100
Register_Value = 11010101

Also refer
How to Check a particular bit is set or not ?
How to set/clear/toggle multiple bit?

Cheers!!!!
-> Let Us Embed <-