Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > User defined data type.

Reply
Thread Tools

User defined data type.

 
 
zacariaz@gmail.com
Guest
Posts: n/a
 
      01-19-2007
Thank you all for all the responses, i actually didnt count on it,
however you say that i am not making sence or being specific enough,
and that does not make sence to me.

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

First of all this is just an example to descibe the problem, the actual
problem is somehwat greater:

union Coord_T {
__int64 id; // long long or whatever. main thing is that its 64 bits
struct {
float xc,yc,zc,tc,xa,ya,za,r; // 8 floats 8 * 32 bit = 256 bits
};
};

Regardles of what types im using float vs. double, int vs. __int64/long
long.
The 8 floating point values just wont fit into ID, just as the ealier
example with 3 doubles and 1 int wont work.
I am still thinking about a way to split things up, but at best i will
be split up into 2, e.g. 128 bit needs to be crammed into the space of
64.
Furthermore im not really that interested in using 64 bit integers,
would prefer 32 bit.

I realize that it might be hard to figure out what i am trying to do
here, but i asure you that it is also very hard to explain.

I dont really count anyone giving a solution. It is one of those
problems that just cant be solved in a proper way i think.

Regards

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Erik_Wikstr=F6m?=
Guest
Posts: n/a
 
      01-19-2007
On 2007-01-19 16:48, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Thank you all for all the responses, i actually didnt count on it,
> however you say that i am not making sence or being specific enough,
> and that does not make sence to me.
>
> union Coord_T {
> int id;
> struct {
> double x;
> double y;
> double z;
> };
> };
>
> First of all this is just an example to descibe the problem, the actual
> problem is somehwat greater:
>
> union Coord_T {
> __int64 id; // long long or whatever. main thing is that its 64 bits
> struct {
> float xc,yc,zc,tc,xa,ya,za,r; // 8 floats 8 * 32 bit = 256 bits
> };
> };
>
> Regardles of what types im using float vs. double, int vs. __int64/long
> long.
> The 8 floating point values just wont fit into ID, just as the ealier
> example with 3 doubles and 1 int wont work.
> I am still thinking about a way to split things up, but at best i will
> be split up into 2, e.g. 128 bit needs to be crammed into the space of
> 64.
> Furthermore im not really that interested in using 64 bit integers,
> would prefer 32 bit.
>
> I realize that it might be hard to figure out what i am trying to do
> here, but i asure you that it is also very hard to explain.


If you could tell us why you need to do this one of us might be able to
help. Am I correct in understanding that you have redefined the problem
from wanting to have a small FP type to wanting a union with a struct of
8 floats/doubles and another type? Does this other type have to be an
integer of some sort? Could it not be more than one, just like the
floats? Something like this:

union Test
{
float data1[8];
char data2[sizeof(float) * 8];
};

--
Erik Wikström
 
Reply With Quote
 
 
 
 
zacariaz@gmail.com
Guest
Posts: n/a
 
      01-20-2007

Erik Wikström skrev:
> On 2007-01-19 16:48, (E-Mail Removed) wrote:
> > Thank you all for all the responses, i actually didnt count on it,
> > however you say that i am not making sence or being specific enough,
> > and that does not make sence to me.
> >
> > union Coord_T {
> > int id;
> > struct {
> > double x;
> > double y;
> > double z;
> > };
> > };
> >
> > First of all this is just an example to descibe the problem, the actual
> > problem is somehwat greater:
> >
> > union Coord_T {
> > __int64 id; // long long or whatever. main thing is that its 64 bits
> > struct {
> > float xc,yc,zc,tc,xa,ya,za,r; // 8 floats 8 * 32 bit = 256 bits
> > };
> > };
> >
> > Regardles of what types im using float vs. double, int vs. __int64/long
> > long.
> > The 8 floating point values just wont fit into ID, just as the ealier
> > example with 3 doubles and 1 int wont work.
> > I am still thinking about a way to split things up, but at best i will
> > be split up into 2, e.g. 128 bit needs to be crammed into the space of
> > 64.
> > Furthermore im not really that interested in using 64 bit integers,
> > would prefer 32 bit.
> >
> > I realize that it might be hard to figure out what i am trying to do
> > here, but i asure you that it is also very hard to explain.

>
> If you could tell us why you need to do this one of us might be able to
> help. Am I correct in understanding that you have redefined the problem
> from wanting to have a small FP type to wanting a union with a struct of
> 8 floats/doubles and another type? Does this other type have to be an
> integer of some sort? Could it not be more than one, just like the
> floats? Something like this:
>
> union Test
> {
> float data1[8];
> char data2[sizeof(float) * 8];
> };
>
> --
> Erik Wikström


I am sorry, but telling what i am doing isnt an option, not because i
dont want to, but im not able to i think.
As for the example posted, i guess it wasnt as understandable as i
thought.
+-----------------------------------------------+
| space in memory |
+-----------------------------------------------+
| 32 or 64 bit integer (preferable 32 bit) |
+-----------------------------------------------+
|float|float|float|float|float|float|float|float|
+-----------------------------------------------+

e.g.
the integertype occupies the same memory allocation as a string og 8
floats.

I fail to see how the union you suggest can help me. I need to cram the
floats into one single var, to get a unique ID dependend on the values
of the floats.

 
Reply With Quote
 
=?ISO-8859-1?Q?Erik_Wikstr=F6m?=
Guest
Posts: n/a
 
      01-20-2007
On 2007-01-20 17:54, (E-Mail Removed) wrote:
> Erik Wikström skrev:
>> On 2007-01-19 16:48, (E-Mail Removed) wrote:
>> > Thank you all for all the responses, i actually didnt count on it,
>> > however you say that i am not making sence or being specific enough,
>> > and that does not make sence to me.
>> >
>> > union Coord_T {
>> > int id;
>> > struct {
>> > double x;
>> > double y;
>> > double z;
>> > };
>> > };
>> >
>> > First of all this is just an example to descibe the problem, the actual
>> > problem is somehwat greater:
>> >
>> > union Coord_T {
>> > __int64 id; // long long or whatever. main thing is that its 64 bits
>> > struct {
>> > float xc,yc,zc,tc,xa,ya,za,r; // 8 floats 8 * 32 bit = 256 bits
>> > };
>> > };
>> >
>> > Regardles of what types im using float vs. double, int vs. __int64/long
>> > long.
>> > The 8 floating point values just wont fit into ID, just as the ealier
>> > example with 3 doubles and 1 int wont work.
>> > I am still thinking about a way to split things up, but at best i will
>> > be split up into 2, e.g. 128 bit needs to be crammed into the space of
>> > 64.
>> > Furthermore im not really that interested in using 64 bit integers,
>> > would prefer 32 bit.
>> >
>> > I realize that it might be hard to figure out what i am trying to do
>> > here, but i asure you that it is also very hard to explain.

>>
>> If you could tell us why you need to do this one of us might be able to
>> help. Am I correct in understanding that you have redefined the problem
>> from wanting to have a small FP type to wanting a union with a struct of
>> 8 floats/doubles and another type? Does this other type have to be an
>> integer of some sort? Could it not be more than one, just like the
>> floats? Something like this:
>>
>> union Test
>> {
>> float data1[8];
>> char data2[sizeof(float) * 8];
>> };
>>
>> --
>> Erik Wikström

>
> I am sorry, but telling what i am doing isnt an option, not because i
> dont want to, but im not able to i think.
> As for the example posted, i guess it wasnt as understandable as i
> thought.
> +-----------------------------------------------+
> | space in memory |
> +-----------------------------------------------+
> | 32 or 64 bit integer (preferable 32 bit) |
> +-----------------------------------------------+
> |float|float|float|float|float|float|float|float|
> +-----------------------------------------------+
>
> e.g.
> the integertype occupies the same memory allocation as a string og 8
> floats.


As we both know, that will never happen.

> I fail to see how the union you suggest can help me. I need to cram the
> floats into one single var, to get a unique ID dependend on the values
> of the floats.


Have you thought about using a hash, with my example you could run some
algorithm over the char-array (or convert it to ints or whatever if that
makes the algorithm easier) so instead of having two fields in the
union, one ID and the floats, you have something like I did and a
function that returns the ID.

--
Erik Wikström
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: __STDC_IEC_559__ (defined or !defined ?) Keith Thompson C Programming 0 08-17-2010 04:36 PM
User-defined exception: "global name 'TestRunError' is not defined" jmike@alum.mit.edu Python 1 07-10-2008 12:37 PM
defined? for recursive function call v/s defined? for function call stack Alok Ruby 3 04-13-2006 11:53 AM
Using parenthesis with defined (#if defined(...)) Angel Tsankov C++ 1 04-05-2006 10:00 PM
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) Oodini C Programming 1 09-27-2005 07:58 PM



Advertisments