用户定义的数据类型。 [英] User defined data type.

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

问题描述

我需要一个特定的非现有数据类型,而且似乎我不是很聪明地编写我自己的代码,所以如果有人会花时间

为我做这件事,他们非常受欢迎,我将永远欢迎

感激不尽。


类型定义:

浮点值。

最大值== +1

最小值== 1


至于精确,我害怕我真的不知道它是如何工作的,但如果是8位,16位或32位,那么最好是



问候

I need a specific non existing data type, and it seems that i am not
smart enough to write the code my self, so if anyone will take the time
to do it for me, they are more than welcome and i will be forever
gratefull.

Type definition:
floating point value.
max value == +1
min value == -1

As for precission, im afraid i dont really know how it work, but it
would be preferable if the would be 8, 16 or 32 bit.

Regards

推荐答案

za ****** @ gmail。 com 在新闻中写道:1169165028.566907.266540

@ v45g2000cwv.googlegroups.com:
za******@gmail.com wrote in news:1169165028.566907.266540
@v45g2000cwv.googlegroups.com:

我需要一个特定的非现有数据类型,似乎我不是足够聪明地编写我自己的代码,所以如果有人花时间

为我做这些,他们更多欢迎,我会永远

感恩。


类型定义:

浮点值。

max value == +1

min value == -1


至于精算,恐怕我真的不知道它是如何工作的,但它

如果是8位,16位或32位则更可取。
I need a specific non existing data type, and it seems that i am not
smart enough to write the code my self, so if anyone will take the time
to do it for me, they are more than welcome and i will be forever
gratefull.

Type definition:
floating point value.
max value == +1
min value == -1

As for precission, im afraid i dont really know how it work, but it
would be preferable if the would be 8, 16 or 32 bit.



即使有人想要为你做功课,你还没有指定足够的信息来实际实现它。如果某人试图将1.5分配给你的对象,那么应该发生什么?


class NewType

{

public:

NewType():internalValue(0.0){};


NewType& operator =(double newVal){x = newVal;返回*这个; };


私人:

double internalValue;

};

NewType x;


x = 1.5;

Even if someone were to want to do your homework for you, you haven''t
specified nearly enough information to actually implement it. Like what is
supposed to happen if someone were to attempt to assign 1.5 to your object?

class NewType
{
public:
NewType() : internalValue(0.0) {};

NewType & operator=(double newVal) { x = newVal; return *this; };

private:
double internalValue;
};
NewType x;

x = 1.5;




Andre Kostur skrev:

Andre Kostur skrev:
za******@gmail.com 在新闻中写道:1169165028.566907.266540

@ v45g2000cwv.googlegroups.com:
za******@gmail.com wrote in news:1169165028.566907.266540
@v45g2000cwv.googlegroups.com:

我需要一个特定的非现有数据类型,而且好像我不是

smart足以让我自己编写代码,所以如果有人花时间

为我做这件事,他们非常欢迎我会永远

感激不尽。


类型定义:

浮点值。

最大值== +1

最小值== -1


至于精确,我担心我真的不知道它是如何工作的,但是如果它是8,16则优惠
或32位。
I need a specific non existing data type, and it seems that i am not
smart enough to write the code my self, so if anyone will take the time
to do it for me, they are more than welcome and i will be forever
gratefull.

Type definition:
floating point value.
max value == +1
min value == -1

As for precission, im afraid i dont really know how it work, but it
would be preferable if the would be 8, 16 or 32 bit.



即使有人想要为你做功课,你还没有指定足够的信息来实际实现它。就像有人试图将1.5分配给你的对象时,应该发生什么?b $ b?


Even if someone were to want to do your homework for you, you haven''t
specified nearly enough information to actually implement it. Like what is
supposed to happen if someone were to attempt to assign 1.5 to your object?



总是人们认为这是家庭作业。我将是最开心的男人

如果是的话,因为这可能意味着我最终将获得

的教育。


"如果有人试图将

1.5分配给你的对象,应该会发生什么?>

和添加2 ^ 32时的情况相同到unsigned int(我应该是

,假设unsigned int可以保持最大2 ^ 32-1)

Allways people think it is homework. I would be the happyest man alive
if it were, as that probably would mean that i would eventually have an
education.

"Like what is supposed to happen if someone were to attempt to assign
1.5 to your object?"
the same thing as when you add 2^32 to an unsigned int (i should be
correct in assuming that an unsigned int can hold max 2^32-1)


>

class NewType

{

public:

NewType():internalValue(0.0){};


NewType& operator =(double newVal){x = newVal;返回*这个; };


私人:

double internalValue;

};


NewType x;


x = 1.5;
>
class NewType
{
public:
NewType() : internalValue(0.0) {};

NewType & operator=(double newVal) { x = newVal; return *this; };

private:
double internalValue;
};
NewType x;

x = 1.5;


oops,过早按下按钮。


这基本上是我需要的;


union Coord_T {

int id;

struct {

double x;

双倍;

双z;

};

};


但是,它是有点困难将3 * 8字节塞进4或8并且

这就是原因,我想要一个用户定义的数据类型。


不知道它是否有用,但就是这样。

oops, pressed the button prematurely.

this is basicly what i need;

union Coord_T {
int id;
struct {
double x;
double y;
double z;
};
};

However, it is somewhat difficult cramming 3*8 byte into 4 or 8 and
thats the reason for ,me wanting a userdefined datatype.

Dont know if it makes sence, but thats the way it is.


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

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