Author Topic: Dealing with REAL10 values  (Read 22606 times)

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Dealing with REAL10 values
« on: April 07, 2013, 02:10:07 AM »
Here is the appropriate 32 bit source from the thread inside the 64 Bit Assembler forum. There are no differences in the C++ source, but a few differences inside the assembly language source.

Gunther
« Last Edit: April 07, 2013, 10:10:57 AM by Gunther »
You have to know the facts before you can distort them.

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1196
Re: Dealing with REAL10 values
« Reply #1 on: April 07, 2013, 02:01:02 AM »
I don’t have time ATM to examine this further, but on my XP system with a recent MinGW installation the 32-bit LongDouble.exe triggers an access violation exception in libstdc++-6!ZSt4cout. Here are the dependencies as returned by Dependency Walker:

KERNEL32.DLL
LIBGCC_S_DW2-1.DLL
LIBSTDC++-6.DLL
LONGDOUBLE.EXE
MSVCRT.DLL
NTDLL.DLL

Well Microsoft, here’s another nice mess you’ve gotten us into.

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: Dealing with REAL10 values
« Reply #2 on: April 07, 2013, 02:18:48 AM »
Michael,

I don’t have time ATM to examine this further, but on my XP system with a recent MinGW installation the 32-bit LongDouble.exe triggers an access violation exception in libstdc++-6!ZSt4cout. Here are the dependencies as returned by Dependency Walker:

KERNEL32.DLL
LIBGCC_S_DW2-1.DLL
LIBSTDC++-6.DLL
LONGDOUBLE.EXE
MSVCRT.DLL
NTDLL.DLL



I could test the 32 bit exe only with Windows XP Mode under Windows 7. Could you re-compile it from the source?

Gunther
You have to know the facts before you can distort them.

qWord

  • Member
  • *****
  • Posts: 1475
  • The base type of a type is the type itself
    • SmplMath macros
Re: Dealing with REAL10 values
« Reply #3 on: April 07, 2013, 02:59:06 AM »
the program requires libgcc_s_dw2-1.dll and libstdc++-6.dll, which can be found in gcc's bin folder.
You maybe use -static-libgcc for linking.

qWord
MREAL macros - when you need floating point arithmetic while assembling!

anta40

  • Member
  • ***
  • Posts: 315
Re: Dealing with REAL10 values
« Reply #4 on: April 07, 2013, 03:27:46 AM »
Gunther's exe also crashes on my laptop, and indeed the cause is libgcc_s_dw2-1.dll not found in my gcc directory.
One possible explanation is Gunther and I are using different distros of mingw.

I'm using this, btw:
http://sourceforge.net/projects/mingwbuilds/files/host-windows/testing/4.8.0/32-bit/threads-win32/sjlj/x32-4.8.0-snapshot-20130315-rev196647-win32-sjlj.7z/download

So I recompile the code, and it works. And actually it's also compilable with MSVC 2012. Attached it for you guys (only dependent on kernel32.dll)  ;)

GCC 4.8 output:
Quote
Layout of data types:
=====================

Long Double (REAL 10)   = 12 Bytes
Double (REAL 8)         =  8 Bytes
Float (REAL 4)          =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = 3.1415926535897932385
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.141593

Press any key to continue ...

MSVC 2012 output:
Quote
Layout of data types:
=====================

Long Double (REAL 10)   = 8 Bytes
Double (REAL 8)         =  8 Bytes
Float (REAL 4)          =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = -8.8796093704934495e+043
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.144531

Press any key to continue ...

jj2007

  • Member
  • *****
  • Posts: 13944
  • Assembly is fun ;-)
    • MasmBasic
Re: Dealing with REAL10 values
« Reply #5 on: April 07, 2013, 03:50:40 AM »
Double (REAL 8)         =  8 Bytes

Double looks real cool, but that's a problem of the forum software ;-)

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: Dealing with REAL10 values
« Reply #6 on: April 07, 2013, 05:53:36 AM »
Hi anta40,

Gunther's exe also crashes on my laptop, and indeed the cause is libgcc_s_dw2-1.dll not found in my gcc directory.
One possible explanation is Gunther and I are using different distros of mingw.

I'm using this, btw:
http://sourceforge.net/projects/mingwbuilds/files/host-windows/testing/4.8.0/32-bit/threads-win32/sjlj/x32-4.8.0-snapshot-20130315-rev196647-win32-sjlj.7z/download

thank you for helping. Indeed, I did use gcc 4.6.2 and that behavior is a bit strange, because C++ isn't Visual Basic which needs sometimes this and that DLL. So, I'll upgrade the compiler.

Gunther
You have to know the facts before you can distort them.

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: Dealing with REAL10 values
« Reply #7 on: April 07, 2013, 06:24:38 AM »
Hi qWord,

the program requires libgcc_s_dw2-1.dll and libstdc++-6.dll, which can be found in gcc's bin folder.
You maybe use -static-libgcc for linking.

qWord

that was my next idea, too. But it doesn't help.

Gunther
You have to know the facts before you can distort them.

Magnum

  • Member
  • *****
  • Posts: 2399
Re: Dealing with REAL10 values
« Reply #8 on: April 07, 2013, 08:26:48 AM »
I am always finding C code, so I may as well assemble it.

I downloaded yasm.

Where would be a good place to get the header and lib files ?

I have some from my 2003 SDK, can I use them ?

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1196
Re: Dealing with REAL10 values
« Reply #9 on: April 07, 2013, 09:35:15 AM »
I forgot to mention that both of the GCC-specific DLLs are in the MinGW bin directory.

After a recompile, with GNU C++ (GCC) version 4.7.2 (mingw32), the app runs OK and I get:
Code: [Select]
Layout of data types:
=====================

Long Double (REAL 10)   = 12 Bytes
Double (REAL 8)         =  8 Bytes
Float (REAL 4)          =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = 3.1415926535897932385
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.141593

:t

Also, I attempted qword’s suggestion:
Code: [Select]
:yasm -f win32 LongDouble.asm
g++ -v -c LongDouble.cpp
pause
g++ -v -static-libgcc -o LongDouble.exe LongDouble.o LongDouble.obj
pause

And while I can’t see anything in the -v output that looks like a warning or error, and the app still functions correctly, the dependencies do not change.
Well Microsoft, here’s another nice mess you’ve gotten us into.

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: Dealing with REAL10 values
« Reply #10 on: April 07, 2013, 10:22:03 AM »
Michael,

thank you for your help. :t

After studying the CERN sources again and again, I've found now the appropriate solution for simple C, too. The new added archive is LongC32.zip and should work fine. Here is the output:
Code: [Select]

Layout of data types:
=====================

Long Double (REAL10)    = 12 Bytes
Double (REAL8)          =  8 Bytes
Float (REAL4)           =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = 3.1415926535897932385
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.141593

Press any key to continue ...

Please check the batch file, because the command line for compiling the C source is a bit tricky. Unfortunately, it won't compile wit VC. But it should work too with Borland's and Intel's C compiler (but that's not tested). The appropriate 64 bit source is LongC64.zip inside that thread.

Gunther
You have to know the facts before you can distort them.

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1196
Re: Dealing with REAL10 values
« Reply #11 on: April 07, 2013, 10:55:05 AM »
This time, the supplied EXE worked correctly.

A bit tricky?

I have in the past spent a significant amount of time trying to do this with a C app compiled with GCC, but who could have guessed that it would take an apparently undocumented:

 -D__USE_MINGW_ANSI_STDIO

switch?

Interesting, the dependencies this time are:

KERNEL32.DLL
LONGPI.EXE
MSVCRT.DLL
NTDLL.DLL

Well Microsoft, here’s another nice mess you’ve gotten us into.

anta40

  • Member
  • ***
  • Posts: 315
Re: Dealing with REAL10 values
« Reply #12 on: April 07, 2013, 11:41:22 AM »
Unfortunately, it won't compile wit VC.

It does  ;)

Code: [Select]
Layout of data types:
=====================

Long Double (REAL10)    = 8 Bytes
Double (REAL8)          =  8 Bytes
Float (REAL4)           =  4 Bytes

Results:
========

PI                      = 3.14159265358979323846264338327 ...
PI as Long Double Value = -88796093704934495000000000000000000000000000.0000000000000000000
PI as Double Value      = 3.141592653589793
PI as Float Value       = 3.144531

Press any key to continue ...


dedndave

  • Member
  • *****
  • Posts: 8828
  • Still using Abacus 2.0
    • DednDave
Re: Dealing with REAL10 values
« Reply #13 on: April 07, 2013, 12:33:02 PM »
that's a lot of digits for a "long double"   :P

ok - 17 signifigant digits - lol
nowhere near PI

Gunther

  • Member
  • *****
  • Posts: 4196
  • Forgive your enemies, but never forget their names
Re: Dealing with REAL10 values
« Reply #14 on: April 07, 2013, 07:58:19 PM »
Michael and anta40,

It does  ;)

yes, it'll compile, but the output is garbage.

that's a lot of digits for a "long double"   :P

ok - 17 signifigant digits - lol
nowhere near PI

There are no long double (REAL10) values in the pure Windows world.

Gunther
You have to know the facts before you can distort them.