8位整数类型 [英] 8 bit integer type

查看:163
本文介绍了8位整数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

typedef char int(myint8);


以上是我想做的事情,但当然不能这样做

方式。我四处寻找8位整数类型,但没有运气。

int8_t和simular仍然像chars。

是的我知道这是一个愚蠢的小事,但我厌倦了写作

int( my8bitvar);所有的时间,如果有一种类型不起作用的话,我想知道。我想知道。


我还试着定义我自己的类型,但是当我不得不使用
实现所有操作符(==, - =,+ =,+, - ,等等)时,它就丢失了

似乎这是一个非常愚蠢的方式。


所以,请任何人都有答案,让我听听。


问候

typedef char int(myint8);

the above is realy what i wanna do, but ofcourse it cant be done this
way. I have looked around for a 8 bit integer type, but no luck. the
int8_t and simular still acts like chars.
Yes i know it a stupid little thing, but im getting tired of writing
int(my8bitvar); all the time, and if there is a type that doesnt act
like a char, i wanna know.

I have allso tryed defining my own type, but got lost when i had to
implement all the operator (==, -=, +=, ++, --, etc.) and besides it
seemed a really stupid way to go about it.

So please i anyone holds an answer, let me hear it.

Regards

推荐答案

2007-08-29 11:45, za ****** @ gmail.com 写道:
On 2007-08-29 11:45, za******@gmail.com wrote:

typedef char int(myint8);


以上是我想做的事情,但当然不能这样做

方式。我四处寻找8位整数类型,但没有运气。

int8_t和simular仍然像chars。

是的我知道这是一个愚蠢的小事,但我厌倦了写作

int( my8bitvar);所有的时间,如果有一种类型不起作用的话,我想知道。
typedef char int(myint8);

the above is realy what i wanna do, but ofcourse it cant be done this
way. I have looked around for a 8 bit integer type, but no luck. the
int8_t and simular still acts like chars.
Yes i know it a stupid little thing, but im getting tired of writing
int(my8bitvar); all the time, and if there is a type that doesnt act
like a char, i wanna know.



char的行为与int的行为有什么不同,除了它可以容纳的

值范围?


-

Erik Wikstr?m

In what way does a char differ in behaviour from an int, except for the
range of values it can hold?

--
Erik Wikstr?m


8月29日12:25,Erik Wikstr? m< Erik-wikst ... @ telia.comwrote:
On 29 Aug., 12:25, Erik Wikstr?m <Erik-wikst...@telia.comwrote:

2007-08-29 11:45,zacar ... @ gmail.com写道:
On 2007-08-29 11:45, zacar...@gmail.com wrote:

typedef char int(myint8);
typedef char int(myint8);


以上是我想做的事情,但当然不能这样做

方式。我四处寻找8位整数类型,但没有运气。

int8_t和simular仍然像chars。

是的我知道这是一个愚蠢的小事,但我厌倦了写作

int( my8bitvar);所有的时间,如果有一种类型不起作用的话,我想知道。
the above is realy what i wanna do, but ofcourse it cant be done this
way. I have looked around for a 8 bit integer type, but no luck. the
int8_t and simular still acts like chars.
Yes i know it a stupid little thing, but im getting tired of writing
int(my8bitvar); all the time, and if there is a type that doesnt act
like a char, i wanna know.



char的行为与int的行为有什么不同,除了它可以容纳的

值范围?


-

Erik Wikstr?m


In what way does a char differ in behaviour from an int, except for the
range of values it can hold?

--
Erik Wikstr?m



当然它没什么不同,但确实有所不同,fx。你怎么想?b $ b当我第一次看到stdint.h并且想尝试uint8-t
时发生了什么?


@code

uint8_t var = 7;

std :: cout<< var;

@code


哎呀!它说。

想象一下我的惊讶。和整数类型发出有趣的声音?

是的,它是一个小小的小东西,没人关心,但是

仍然让我不得不写下来

std :: cout<< int(var);

是的,它只有5个额外的字母,这取决于,但是这个帖子的目标只是为了确保真正的8位整数类型或

一个简单的解决方案并不是全部已经准备好了。

Of course it doesnt differ much, but it does differ, fx. what do you
think happened when i first head about the stdint.h and wanted to try
out the uint8-t?

@code
uint8_t var = 7;
std::cout << var;
@code

BEEP! it said.
Imagine my surprise. and integer type making funny noises?
Yes, it is a tiny little wee wee thing that nobody care about, but
still it enoys me having to write
std::cout << int(var);
Yes, it is only 5 extra letter, well that depends, but the goal of
this post was only to make certain that a real 8 bit integer type or
an easy soluton doesnt allready excist.


2007-08-29 12:35, za ****** @ gmail.com 写道:
On 2007-08-29 12:35, za******@gmail.com wrote:

8月29日,12:25,Erik Wikstr?m< Erik-wikst ... @ telia.comwrote:
On 29 Aug., 12:25, Erik Wikstr?m <Erik-wikst...@telia.comwrote:

> 2007-08-29 11:45,zacar ... @ gmail.com写道:
>On 2007-08-29 11:45, zacar...@gmail.com wrote:

typedef char int(myint8);
typedef char int(myint8);


以上是我想做的事情,但当然不能这样做

方式。我四处寻找8位整数类型,但没有运气。

int8_t和simular仍然像chars。

是的我知道这是一个愚蠢的小事,但我厌倦了写作

int( my8bitvar);所有的时间,如果有一种类型不起作用的话,我想知道。
the above is realy what i wanna do, but ofcourse it cant be done this
way. I have looked around for a 8 bit integer type, but no luck. the
int8_t and simular still acts like chars.
Yes i know it a stupid little thing, but im getting tired of writing
int(my8bitvar); all the time, and if there is a type that doesnt act
like a char, i wanna know.


char的行为与int的行为有什么不同,除了它可以容纳的
值范围?

- Erik Wikstr?m


In what way does a char differ in behaviour from an int, except for the
range of values it can hold?

--
Erik Wikstr?m



当然它没有多大区别,但确实有所不同,fx。你怎么想?b $ b当我第一次看到stdint.h并且想尝试uint8-t
时发生了什么?


@code

uint8_t var = 7;

std :: cout<< var;

@code


哎呀!它说。

想象一下我的惊讶。和整数类型发出有趣的声音?


是的,这是一个小小的小小的东西,没有人关心,但

仍然让我不得不写

std :: cout<< int(var);

是的,它只有5个额外的字母,这取决于,但是这个帖子的目标只是为了确保真正的8位整数类型或

一个简单的解决方案并不是全部已经准备好了。


Of course it doesnt differ much, but it does differ, fx. what do you
think happened when i first head about the stdint.h and wanted to try
out the uint8-t?

@code
uint8_t var = 7;
std::cout << var;
@code

BEEP! it said.
Imagine my surprise. and integer type making funny noises?
Yes, it is a tiny little wee wee thing that nobody care about, but
still it enoys me having to write
std::cout << int(var);
Yes, it is only 5 extra letter, well that depends, but the goal of
this post was only to make certain that a real 8 bit integer type or
an easy soluton doesnt allready excist.



是的,我明白了。这当然是因为uint8_t只是一个

unsigned char的typedef。我不认为除了编译器供应商或库

供应商可以解决这个问题。


-

Erik Wikstr ?m

Yes, I see. This is of course because uint8_t is just a typedef of an
unsigned char. I don''t think anyone but the compiler vendor or library
vendor can fix this.

--
Erik Wikstr?m


这篇关于8位整数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆