Re: Big numbers



"marc" <marc.tessis@xxxxxxxxxxxx> wrote in message news:95e1eae0-1267-4985-8362-2b06001a9f32@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,

I get a number like 33748440199875750.25 from a database.
I must convert it to a string.
How could I do ?
I tried double, float, _int64, etc... I always lose precison (eg, I
get 33748440199875752. => + 2 ) before converting it.
I know it's relative to IEEE, but I can't find a solution to simply
convert it to a string

Thanks in advance.

I guess you could try something out that is analogous to the following MSVC++ specific code:
___________________________________________________________________
#include <stdio.h>


struct number_parts {
char sign;
unsigned __int64 decimal;
unsigned __int64 non_decimal;
};


union number {
struct number_parts parts;
unsigned char buf[sizeof(struct number_parts)];
};


int main(void) {
union number x;

x.parts.sign = '+';
x.parts.decimal = 25;
x.parts.non_decimal = 33748440199875750;

printf("%c%I64u.%I64u\n", x.parts.sign, x.parts.non_decimal, x.parts.decimal);

return 0;
}
___________________________________________________________________


lol! ;^)

.



Relevant Pages

  • Re: Unions in C Sharp
    ... In this case you need to marshall the number as Explicit but the string as ... > typedef union ChannelProtocol { ... > struct { ... >>> functions in an unmanaged DLL that has a struct with unions in it as a ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Unions and Structure Questions
    ... >string fname ... >If I am wrong please correct me, also why would one want to use a union over ... In a struct, none of the members overlap. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: A little Rolodex [revised]
    ... including alpha sort and searching for any embedded string, ... In this application, a database is a directory, ... you may optionally provide any alternate UCASE program, ... NN -> first store NN as key length ...
    (comp.sys.hp48)
  • Re: return multiple rows from sql statement
    ... strings from input values is almost certainly a safe path to SQL ... Also, being a MySQL function, it knows what MySQL needs or uses. ... All characters that are entered in the fields make their way into the database unaltered. ... The insert of what surprisinlgly was NOT a syntax error, but a string called "mysql_insert_id" into an integer field resulted in the value zero being put in. ...
    (comp.lang.php)
  • Re: how to store list of varying types
    ... When there's a variable-length string, ... typedef struct { ... pointer null, and the second one the CString object. ... then have to finish constructing the packet by copying the two data objects ...
    (microsoft.public.vc.mfc)