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

From: Oleg Shalnev <ovs(at)megalog(dot)ru>
To: Mike Mascari <mascarm(at)mascari(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How To Get Numetic Value!!! using C ???
Date: 2002-11-26 15:09:00
Message-ID: 3DE38E8C.1020002@megalog.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)mascari(dot)com
>
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Aurangzeb M. Agha 2002-11-26 15:16:42 Updating record drops it to the bottom
Previous Message Gianfranco Masia - Eprom s.r.l. 2002-11-26 14:48:30 Compatibility of future releases