Thread: How To Get Numetic Value!!! using C ???

How To Get Numetic Value!!! using C ???

From
Oleg Shalnev
Date:
Hi All!


I want to GetValue numeric type from binary cursor, but I have no ideas
how to do it.
Now I am using

double test;
test=atof((char*)GetValue(0,0));
in C function and doing
to_char(my_numeric_field, '9999999999999D99')
in database selection.
May be there is another normal way to do it.

Thanks a lot!!!
Oleg Shalnev


Re: How To Get Numetic Value!!! using C ???

From
Mike Mascari
Date:
Oleg Shalnev wrote:
> Hi All!
>
>
> I want to GetValue numeric type from binary cursor, but I have no ideas
> how to do it.
> Now I am using
>
> double test;
> test=atof((char*)GetValue(0,0));
> in C function and doing
> to_char(my_numeric_field, '9999999999999D99')
> in database selection.
> May be there is another normal way to do it.
>
> Thanks a lot!!!
> Oleg Shalnev

First, I'd not use binary cursors because:

1) I have no clue regarding the binary representation of Numeric
2) Byte-ordering can differ if the client and server platforms
are different

I'm surprised the above works at all with a binary cursor.
Assuming a text cursor, I think you need some additional C/C++
library which has:

1) support for ASCII to fixed-point conversion
2) support for fixed-point to ASCII conversion
3) fixed-point operations

My clients are CORBA-based C++, which has a "Fixed" class
supplied by the vendor to handle the above. Java, likewise, has
BigDecimal. You might want to do a search for "arbitrary
precision library C". A quick search included this:

http://www.swox.com/gmp/#DOC

which appears to do what you need to do on the client, and a
whole lot more...

How that helps,

Mike Mascari
mascarm@mascari.com






Re: How To Get Numetic Value!!! using C ???

From
Oleg Shalnev
Date:
Mike Mascari wrote:

> Oleg Shalnev wrote:
>
>> Hi All!
>

Thanks a lot!

Oleg Shalnev

>>
>>
>>
>> I want to GetValue numeric type from binary cursor, but I have no
>> ideas how to do it.
>> Now I am using
>>
>> double test;
>> test=atof((char*)GetValue(0,0));
>> in C function and doing
>> to_char(my_numeric_field, '9999999999999D99')
>> in database selection.
>> May be there is another normal way to do it.
>>
>> Thanks a lot!!!
>> Oleg Shalnev
>
>
> First, I'd not use binary cursors because:
>
> 1) I have no clue regarding the binary representation of Numeric
> 2) Byte-ordering can differ if the client and server platforms are
> different
>
> I'm surprised the above works at all with a binary cursor. Assuming a
> text cursor, I think you need some additional C/C++ library which has:
>
> 1) support for ASCII to fixed-point conversion
> 2) support for fixed-point to ASCII conversion
> 3) fixed-point operations
>
> My clients are CORBA-based C++, which has a "Fixed" class supplied by
> the vendor to handle the above. Java, likewise, has BigDecimal. You
> might want to do a search for "arbitrary precision library C". A quick
> search included this:
>
> http://www.swox.com/gmp/#DOC
>
> which appears to do what you need to do on the client, and a whole lot
> more...
>
> How that helps,
>
> Mike Mascari
> mascarm@mascari.com
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>