what data type is fast ?

Write here if you have problems with your C source code

Moderator: Board moderators

Post Reply
mohiul alam prince
Experienced poster
Posts: 120
Joined: Sat Nov 01, 2003 6:16 am
Location: Dhaka (EWU)

what data type is fast ?

Post by mohiul alam prince »

Hi

what data type is fast ?
-bool
-char
if u know please reply me.

MAP
Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post by Larry »

They both use up one byte.. and there isn't really a bool in pure C..
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim »

say, if bool and char use up one byte, then what was the point of introducing bool type in ANSI C++, is it just to be in accordance with other languages that have a bool data type.
sumankar
A great helper
Posts: 286
Joined: Tue Mar 25, 2003 8:36 am
Location: calcutta
Contact:

Post by sumankar »

AFAIK the latest C standard defines two things:

1. bool data type (for which you need the stdbool.h header)
2. _Bool in case you don't want the former breaking legacy code,
this one being a macro with the added advantage that it can #undef-ed.

I will need to look up the size of the former though, but most likely as with others it must be left to the implementors.

Regards,
Suman.
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

Code: Select all

joachim@joabox[bool]$ gcc -dumpversion
3.3.4
joachim@joabox[bool]$ cat testbool.c
#include <stdio.h>
#include <stdbool.h>

int main(){

   printf("%d\n",sizeof(bool));
   return 0;
   }
joachim@joabox[bool]$ gcc testbool.c
joachim@joabox[bool]$ a.out
1
joachim@joabox[bool]$
mohiul alam prince
Experienced poster
Posts: 120
Joined: Sat Nov 01, 2003 6:16 am
Location: Dhaka (EWU)

Post by mohiul alam prince »

Hi
which data type is profitable for visit a index char of bool.:o

- I want to add two value with bit operation how can i do that. and also
multiplication.

- Is there any bit wise visiting operation. (that i can get very quickly)

If any body know about this thing please reply me. :)

thankx

MAP
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim »

Mohiul, this post will not fulfill your requirement entirely, but I advise you to study bitset of C++ STL. There are features that might interest you. :wink:
Ronald29
New poster
Posts: 15
Joined: Sat May 24, 2003 3:57 am

Post by Ronald29 »

mohiul, do you want to access a variable in bit? you can use the bit wise operation, use the '&' operator
Ronald29
New poster
Posts: 15
Joined: Sat May 24, 2003 3:57 am

Post by Ronald29 »

mohiul, do you want to access a variable in bit? you can use the bit wise operation, use the '&' operator
Post Reply

Return to “C”