On 7/21/2012 15:06, Sisyphus wrote: > Hi, > > I'm using a mingw64 port of gcc-4.7.0 on Windows Vista64: > > ############################# > C:\_32\C>x86_64-w64-mingw32-gcc -v > Using built-in specs. > COLLECT_GCC=x86_64-w64-mingw32-gcc > COLLECT_LTO_WRAPPER=c:/_64/alt/bin/../libexec/gcc/x86_64-w64-mingw32/4.7.0/lto-wrapper.exe > Target: x86_64-w64-mingw32 > Configured with: > ../../../build/gcc/src/configure --target=x86_64-w64-mingw32 > --prefix=/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/root > --with-sysroot=/c/bb/vista64-mingw32/mingw-x86-x86_64/build/build/root > --enable-languages=all,obj-c++ > --enable-fully-dynamic-string --disable-multilib > Thread model: win32 > gcc version 4.7.0 20110410 (experimental) (GCC) > ############################ > > I'm just starting to play with the _Decimal64 type. > First thing I'm wondering is how we reliably print out the _Decimal64 values > in our programs. Is there a formatter we can use with printf() ? > > For the moment, I've simply been casting the _Decimal64 variable to a double > and formatting with %f: > printf("%f\n", (double)decimal64); > > That's good enough to show me that I'm getting sane values - though I think > I ought to find out how to do it correctly. > > I did, however, come across something that appears to me to be *not* so > sane: > > ############################ > #include <stdio.h> > #include <stdlib.h> > > int main(void) { > _Decimal64 inf_d64, nan_d64; > double inf_d, nan_d; > > inf_d64 = 1.0DD/0.0DD; > inf_d = 1.0/0.0; > > nan_d64 = inf_d64/inf_d64; > nan_d = inf_d/inf_d; > > printf("%f %f\n", (double)nan_d64, nan_d); > > nan_d64 = -nan_d64; > nan_d = -nan_d; > > printf("%f %f\n", (double)nan_d64, nan_d); > > return 0; > } > > /********************** > Outputs: > 1.#QNAN0 -1.#IND00 > -1.#IND00 1.#QNAN0 > > Expected: > -1.#IND00 -1.#IND00 > 1.#QNAN0 1.#QNAN0 > ***********************/ > ############################ > > Whereas the "positive" nan is usually represented as -1.#IND00 and the > "negative" nan as 1.#QNAN0, the _Decimal64 nans are (it seems) being > represented the other way about. > > Is this just a consequence of my improper way of printing those _Decimal64 > values ? > What ought we see when we print a _Decimal64 nan on Windows? > > Cheers, > Rob >
I'm surprised it works at all, the decimal float math support routines are missing from mingw-w64 crt. Other than that, I can't really comment on the correctness. Perhaps you can look at <http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801?ciid=8cf166fedd1aa110VgnVCM100000a360ea10RCRD> for reference.
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public