1. The fate of EuCOM with gotos....

Sorry guys, couldn't resist!

Matt, I did some reading (based on the links you provided) on the
VT_DECIMAL variant for EuCOM.  The decimal variant is:

  type DECIMAL
        sequence   
        integer(SHORT_KIND)::wReserved   
        integer(BYTE_KIND)::scale   
        integer(BYTE_KIND)::sign   
        integer(LONG_KIND)::Hi32   
        integer(LONG_KIND)::Lo32   
        integer(LONG_KIND)::Mid32
    end type DECIMAL

How do you think the decimal value would be derived from Hi32,Lo32 and
Mid32?  Also according to what I read, a VT_DECIMAL can have up to 28
decimal positions.  Will this be a problem when converting to a Euphoria
atom that can only handle up to 15?

Jonas Temple
http://www.yhti.net/~jktemple

new topic     » topic index » view message » categorize

2. Re: The fate of EuCOM with gotos....

Jonas Temple wrote:
> 
> Sorry guys, couldn't resist!

Whew!  The title had me worried!

> Matt, I did some reading (based on the links you provided) on the
> VT_DECIMAL variant for EuCOM.  The decimal variant is:
> 
>   type DECIMAL
>         sequence   
>         integer(SHORT_KIND)::wReserved   
>         integer(BYTE_KIND)::scale   
>         integer(BYTE_KIND)::sign   
>         integer(LONG_KIND)::Hi32   
>         integer(LONG_KIND)::Lo32   
>         integer(LONG_KIND)::Mid32
>     end type DECIMAL
> 
> How do you think the decimal value would be derived from Hi32,Lo32 and
> Mid32?  Also according to what I read, a VT_DECIMAL can have up to 28
> decimal positions.  Will this be a problem when converting to a Euphoria
> atom that can only handle up to 15?

Interesting...I think it could be a problem.  You'll either lose precision
(assuming that it really has that many significant digits), or you'll need
to store it in some other format (text, or a big number library).

If it wasn't apparent from googling (and it wasn't during the 5 min or so
that I did...maybe some more is warranted) then I'd recommend looking at
some known output, and reverse engineering.  I'll have to see if I have
anything that will produce decimal values...Where are you getting them?

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

3. Re: The fate of EuCOM with gotos....

Matt Lewis wrote:

> > How do you think the decimal value would be derived from Hi32,Lo32 and
> > Mid32?  Also according to what I read, a VT_DECIMAL can have up to 28
> > decimal positions.  Will this be a problem when converting to a Euphoria
> > atom that can only handle up to 15?
> 
> Interesting...I think it could be a problem.  You'll either lose precision
> (assuming that it really has that many significant digits), or you'll need
> to store it in some other format (text, or a big number library).
> 
> If it wasn't apparent from googling (and it wasn't during the 5 min or so
> that I did...maybe some more is warranted) then I'd recommend looking at
> some known output, and reverse engineering.  I'll have to see if I have
> anything that will produce decimal values...Where are you getting them?
> 
I'm getting the values from an IBM AS/400 running DB2.  The numeric values
I'm getting are defined as a fixed number of decimals (15,5) which is
fairly common on this type of machine.  If you want to run a test then I
can arrange for you to run the client install that will put the ADO 
provider on your machine.

Incidentally, I'm still running into situations where a get of a string
field's value will return the actual string in some instances and in 
other instances it will return a numeric value that has to be fed to
peek_bstr().  Weird, huh?  If you install the ADO provider for my 
AS/400 then I might be able to provide some examples.

Please don't think that I want you to do all the work here!  I want to 
learn how it's all put together but I haven't been able to find a 
starting point to figure out how the functions are put together.  Can you
at least point me in the right direction?

Thanks!

Jonas Temple
http://www.yhti.net/~jktemple

new topic     » goto parent     » topic index » view message » categorize

4. Re: The fate of EuCOM with gotos....

Jonas Temple wrote:
> 
> I'm getting the values from an IBM AS/400 running DB2.  The numeric values
> I'm getting are defined as a fixed number of decimals (15,5) which is
> fairly common on this type of machine.  If you want to run a test then I
> can arrange for you to run the client install that will put the ADO 
> provider on your machine.

Thanks, but I think I have another way to make them.
 
> Incidentally, I'm still running into situations where a get of a string
> field's value will return the actual string in some instances and in 
> other instances it will return a numeric value that has to be fed to
> peek_bstr().  Weird, huh?  If you install the ADO provider for my 
> AS/400 then I might be able to provide some examples.
> 
> Please don't think that I want you to do all the work here!  I want to 
> learn how it's all put together but I haven't been able to find a 
> starting point to figure out how the functions are put together.  Can you
> at least point me in the right direction?

Try this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap7_5alv.asp

You might be able to use these functions to change a decimal to a double
or something.  Otherwise, perhaps if you could post the contents of the
VT_DECIMAL (i.e.,  peek( {variant,16} ) )  we might be able to figure it
out.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

5. Re: The fate of EuCOM with gotos....

Matt Lewis wrote:
> 
> 
> Try this:
> 
> <a
> href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap7_5alv.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap7_5alv.asp</a>
> 
> You might be able to use these functions to change a decimal to a double
> or something.  Otherwise, perhaps if you could post the contents of the
> VT_DECIMAL (i.e.,  peek( {variant,16} ) )  we might be able to figure it
> out.
> 

OK, I found the variant conversion functions.  Specifically, you probably
want to use VarR8FromDec.  Basically, the decimal type seems to store
a really big integer (96-bytes!), plus the sign and where to put the
decimal point.  The docs for VarR8FromDec are here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap7_9yn7.asp

Here's a little test I just did:

include eucom.ew

constant
VarDecFromR8 = define_c_func( oleaut32, "VarDecFromR8", {C_DOUBLE, C_POINTER},
C_LONG ),
VarR8FromDec = define_c_func( oleaut32, "VarR8FromDec", {C_POINTER, C_POINTER},
C_LONG )
atom ptr
ptr = allocate( 24 )

mem_set( ptr, 0, 16 )
? c_func( VarDecFromR8, { 123456789012345, ptr })
? peek4u( ptr & 4 )

? c_func( VarR8FromDec, { ptr, ptr + 16})
printf(1,"%d\n%d\n", float64_to_atom( peek( (ptr + 16) & 8) ) & 123456789012345)

? 1/0


Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu