[comp.sys.amiga] Lattice atof

R_MCINTI%UNHH.BITNET@mitvma.mit.edu (09/06/90)

> regarding the atof() problem in lattice "C"

The atof() seems to work fine; the difficulty is in the
printf() routine. I beleive with many vendors there are
two seperate printf() functions; one for interger math , and
one for double precision. It is perhaps the latter function
that is too blame - in fact it may not exist - which would explain
why when you write printf("%f",double_number) you end up with "%f"
on the screen since the first function is unaware of the %f option, therefore
treats it as though it is a string.

To sum up - Yeah I think it's a bug and it has been bothering me for some time!

akk@trantor.informatik.uni-erlangen.de (Andreas K. Klingler) (09/08/90)

In article <29545@nigel.ee.udel.edu> R_MCINTI%UNHH.BITNET@mitvma.mit.edu writes:
>> regarding the atof() problem in lattice "C"
>
>The atof() seems to work fine; the difficulty is in the
>printf() routine. I beleive with many vendors there are
>two seperate printf() functions; one for interger math , and
>one for double precision. It is perhaps the latter function
>that is too blame - in fact it may not exist - which would explain
>why when you write printf("%f",double_number) you end up with "%f"
>on the screen since the first function is unaware of the %f option, therefore
>treats it as though it is a string.
>
>To sum up - Yeah I think it's a bug and it has been bothering me for some time!

Try linking with a math library e.g. lcm.lib. This should solve your 'bug'.
--
Andreas Klingler
akk@trantor.informatik.uni-erlangen.de
     A business is no business until you have shown the revenue office
			it was no business

R_MCINTI%UNHH.BITNET@mitvma.mit.edu (09/11/90)

In article <29545@nigel.ee.udel.edu> R_MCINTI%UNHH.BITNET@mitvma.mit.edu writes:
>>> regarding the atof() problem in lattice "C"
>>
>>The atof() seems to work fine; the difficulty is in the
>>printf() routine. I beleive with many vendors there are
>>two seperate printf() functions; one for interger math , and
>>one for double precision. It is perhaps the latter function
>>that is too blame - in fact it may not exist - which would explain
>>why when you write printf("%f",double_number) you end up with "%f"
>>on the screen since the first function is unaware of the %f option, therefore
>>treats it as though it is a string.
>>
>>To sum up - Yeah I think it's a bug and it has been bothering me for some time
!

>Try linking with a math library e.g. lcm.lib. This should solve your 'bug'.
--
>Andreas Klingler
>akk@trantor.informatik.uni-erlangen.de
>     A business is no business until you have shown the revenue office
>                       it was no business

Please - no more - Oh-little-boys-please-link-with-lcm.lib.
The FACTS:
- Using Lattice C 5.02
- Including <math.h> or <m68881.h> with appropriate math libraries linked in
        before lc.lib

PROBLEM: atof() works - But how do you print it out? printf() with the %f or
%g option does not seem to work.- Bug ?

Thanks in advance for any help. - Scott McIntire

new@ee.udel.edu (Darren New) (09/11/90)

In article <30123@nigel.ee.udel.edu> R_MCINTI%UNHH.BITNET@mitvma.mit.edu writes:
>PROBLEM: atof() works - But how do you print it out? printf() with the %f or
>%g option does not seem to work.- Bug ?

I just ran into something similar. When I removed -rr from the LC line,
the bugs went away.  Before that, all floats were close to zero but not
close enough to keep from crashing printf() ?!?   Try recompiling
and relinking everything without the -rr (if you are using it).
My problem sure looked like a bug to me.   (P.S., I'm still back
at 5.04).              -- Darren
-- 
--- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
----- Network Protocols, Graphics, Programming Languages, 
      Formal Description Techniques (esp. Estelle), Coffee -----

walker@unx.sas.com (Doug Walker) (09/12/90)

In article <29545@nigel.ee.udel.edu> R_MCINTI%UNHH.BITNET@mitvma.mit.edu writes:
>> regarding the atof() problem in lattice "C"
>
>The atof() seems to work fine; the difficulty is in the
>printf() routine. I beleive with many vendors there are
>two seperate printf() functions; one for interger math , and
>one for double precision. It is perhaps the latter function
>that is too blame - in fact it may not exist - which would explain
>why when you write printf("%f",double_number) you end up with "%f"
>on the screen since the first function is unaware of the %f option, therefore
>treats it as though it is a string.
>


You're totally correct; there is a non-floating-point version of printf
in lc.lib that ignores %f, %g and the like.  This is in order to save 
space in the final executable.  Make sure you're linking with a math 
library (lcm.lib, for example) BEFORE lc.lib and amiga.lib.  If it's
not listed BEFORE lc.lib, the printf in lc.lib will get picked up as
your printf, and you won't see any substitution for the %f.


  *****
=*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
 *|. o.| ||
  | o  |//     For all you do, this bug's for you!
  ====== 
usenet: ...mcnc!rti!sas!walker   plink: dwalker  bix: djwalker 

d87-khd@sm.luth.se (Karl-Gunnar Hultland) (09/14/90)

In article <30123@nigel.ee.udel.edu> R_MCINTI%UNHH.BITNET@mitvma.mit.edu writes:
>Please - no more - Oh-little-boys-please-link-with-lcm.lib.
>The FACTS:
>- Using Lattice C 5.02
>- Including <math.h> or <m68881.h> with appropriate math libraries linked in
>        before lc.lib
>
>PROBLEM: atof() works - But how do you print it out? printf() with the %f or
>%g option does not seem to work.- Bug ?
>
>Thanks in advance for any help. - Scott McIntire

My guess is that you are using the _builtin_printf which get defined in
stdio.h, examine it and do the proper #undef.
The builtin version is smaller but supports only integer and string output.

				Karl

---

Karl Hultland,(d87-khd@sm.luth.se)
University of Lulea,Sweden

Revolution: in politics, an abrupt change in the form of misgovernment.
						- A. Bierce

walker@unx.sas.com (Doug Walker) (09/20/90)

In article <30123@nigel.ee.udel.edu> R_MCINTI%UNHH.BITNET@mitvma.mit.edu writes:
>
>The FACTS:
>- Using Lattice C 5.02
>- Including <math.h> or <m68881.h> with appropriate math libraries linked in
>        before lc.lib
>
>PROBLEM: atof() works - But how do you print it out? printf() with the %f or
>%g option does not seem to work.- Bug ?
>
>Thanks in advance for any help. - Scott McIntire

There is no known bug in the 5.02 libraries with %f or %g.  I am still not
convinced you are getting the right printf.  Make sure you are using lcmr.lib
if you are using registerized parameters (-rr).  Use the cross-reference
and map to determine where your printf comes from.  Leave off lc.lib or
lcr.lib from your link line and make SURE that printf doesn't come through
as undefined.  (Actually link with JUST the math library and make sure it
does get defined.)  Are your math libraries linked in before amiga.lib as
well?  (They should be.)  Compile this:

#include <stdio.h>
void main(void) {printf("%g\n", 0.0);}

with the line 'lc -Lm test' and see if it works correctly.  What compile
line are you using?  What math options?  What link line?


  *****
=*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
 *|. o.| ||
  | o  |//     For all you do, this bug's for you!
  ====== 
usenet: ...mcnc!rti!sas!walker   plink: dwalker  bix: djwalker 

walker@unx.sas.com (Doug Walker) (09/20/90)

In article <30126@nigel.ee.udel.edu> new@ee.udel.edu (Darren New) writes:
>
>I just ran into something similar. When I removed -rr from the LC line,
>the bugs went away.  Before that, all floats were close to zero but not
>close enough to keep from crashing printf() ?!?   Try recompiling
>and relinking everything without the -rr (if you are using it).
>My problem sure looked like a bug to me.   (P.S., I'm still back
>at 5.04).              -- Darren

That sounds like you're using the wrong math library.  were you linking
with lcmr.lib?


  *****
=*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
 *|. o.| ||
  | o  |//     For all you do, this bug's for you!
  ====== 
usenet: ...mcnc!rti!sas!walker   plink: dwalker  bix: djwalker 

new@ee.udel.edu (Darren New) (09/20/90)

In article <1990Sep19.174418.22665@unx.sas.com> walker@unx.sas.com (Doug Walker) writes:
>
>In article <30126@nigel.ee.udel.edu> new@ee.udel.edu (Darren New) writes:
>>I just ran into something similar. When I removed -rr from the LC line,
>>the bugs went away.  
>That sounds like you're using the wrong math library.  were you linking
>with lcmr.lib?

Well, my compile line is:

LC -iINCLUDE: -rr -cafkrsu -M {f1} {f2} {f3} {f4} ...

I link with Tess.link, which contains:

FROM LIB:c.o+Tess.o+TessLo.o+TessHi.o+Cube.o+Files.o+*
Keys.o+Util3.o+XForm3.o+Util4.o+XForm4.o+ILBM.o+*
WriteIlbm.o+Mesg.o
TO Tess
LIB lib:lcmr.lib+lib:DBugLib.lib+LIB:lcr.lib+LIB:amiga.lib

When I take out -rr and the 'r's from the ends of the library names, it
works. (DBugLib is mine, and does not currently get called.)  When I
put them in, any attempt to use printf to print a float or double
causes an infinite number of '0' characters to print, and often GURUs
and/or stomps low memory.    Looks like a bug to me.   Any suggestions?
			-- Darren
-- 
--- Darren New --- Grad Student --- CIS --- Univ. of Delaware ---
----- Network Protocols, Graphics, Programming Languages, 
      Formal Description Techniques (esp. Estelle), Coffee -----

walker@unx.sas.com (Doug Walker) (09/24/90)

In article <31003@nigel.ee.udel.edu> new@ee.udel.edu (Darren New) writes:
>
>When I take out -rr and the 'r's from the ends of the library names, it
>works. (DBugLib is mine, and does not currently get called.)  When I
>put them in, any attempt to use printf to print a float or double
>causes an infinite number of '0' characters to print, and often GURUs
>and/or stomps low memory.    Looks like a bug to me.   Any suggestions?
>			-- Darren

If this is 5.02, it might be a parameter passign bug that was fixed
in 5.04.  Call SAS tech support at (919)677-8000 or write to them

Amiga C Technical Support
SAS Institute, Inc
SAS Campus Drive
Cary, NC 27513
 
and they will resolve it for you.  (I try to help, but I'm NOT tech
support, and supporting the product over the net is against net
policy anyway.)


  *****
=*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
 *|. o.| ||
  | o  |//     For all you do, this bug's for you!
  ====== 
usenet: ...mcnc!rti!sas!walker   plink: dwalker  bix: djwalker