9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] float.h
@ 2008-08-05 19:07 Pietro Gagliardi
  2008-08-05 23:43 ` Russ Cox
  0 siblings, 1 reply; 11+ messages in thread
From: Pietro Gagliardi @ 2008-08-05 19:07 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello. Is there an alternative to the macros in this header? My
program uses some of them (DBL_MIN, DBL_MAX, DBL_EPSILON), and
including <ape/float.h> yields name clashes. Thanks.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-05 19:07 [9fans] float.h Pietro Gagliardi
@ 2008-08-05 23:43 ` Russ Cox
  2008-08-06  2:51   ` Pietro Gagliardi
  0 siblings, 1 reply; 11+ messages in thread
From: Russ Cox @ 2008-08-05 23:43 UTC (permalink / raw)
  To: 9fans

> Hello. Is there an alternative to the macros in this header? My
> program uses some of them (DBL_MIN, DBL_MAX, DBL_EPSILON), and
> including <ape/float.h> yields name clashes. Thanks.

Why not change your program not to use
standard names for its own purposes?

Russ



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-05 23:43 ` Russ Cox
@ 2008-08-06  2:51   ` Pietro Gagliardi
  2008-08-06  3:14     ` ron minnich
  0 siblings, 1 reply; 11+ messages in thread
From: Pietro Gagliardi @ 2008-08-06  2:51 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Aug 5, 2008, at 7:43 PM, Russ Cox wrote:

>> Hello. Is there an alternative to the macros in this header? My
>> program uses some of them (DBL_MIN, DBL_MAX, DBL_EPSILON), and
>> including <ape/float.h> yields name clashes. Thanks.
>
> Why not change your program not to use
> standard names for its own purposes?
>
> Russ
>
>

In this case, "its own purposes" == "allowing the user to choose that
as a parameter to an expression."




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-06  2:51   ` Pietro Gagliardi
@ 2008-08-06  3:14     ` ron minnich
  2008-08-06  3:22       ` Pietro Gagliardi
  0 siblings, 1 reply; 11+ messages in thread
From: ron minnich @ 2008-08-06  3:14 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I'm so confused. Why don't you just show the code.

ron



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-06  3:14     ` ron minnich
@ 2008-08-06  3:22       ` Pietro Gagliardi
  2008-08-06  8:06         ` Charles Forsyth
  2008-08-06 16:29         ` Greg Comeau
  0 siblings, 2 replies; 11+ messages in thread
From: Pietro Gagliardi @ 2008-08-06  3:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Aug 5, 2008, at 11:14 PM, ron minnich wrote:

> I'm so confused. Why don't you just show the code.
>
> ron
>

#include <u.h>
...
#include <ape/float.h>
...

static struct{
	char *name;
	double value;
}constants[] = {
	...
	"MIN",		DBL_MIN,
	"MAX",		DBL_MAX,
	"EPSILON",	DBL_EPSILON,
	...
};

I'm actually writing a calculator that will take advantage of several
features of Plan 9 (Runes, libgeometry, etc.) and I'd like to make
these available.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-06  3:22       ` Pietro Gagliardi
@ 2008-08-06  8:06         ` Charles Forsyth
  2008-08-06 12:43           ` Pietro Gagliardi
  2008-08-06 16:29         ` Greg Comeau
  1 sibling, 1 reply; 11+ messages in thread
From: Charles Forsyth @ 2008-08-06  8:06 UTC (permalink / raw)
  To: 9fans

>My  program uses some of them (DBL_MIN, DBL_MAX, DBL_EPSILON), and
>including <ape/float.h> yields name clashes. Thanks.

> #include <u.h>
> ...
> #include <ape/float.h>

it's surprisingly important not to leave out important information, such as
what important things were in the "..." (other include files) and, most importantly, the particular "name clashes".

i'd noticed you were using <ape/float.h> not <float.h> which i'd thought curious
(were you mixing APE and Plan 9 include files?) but like most others i'd initially
assumed the "name clashes" had to do with the DBL_ names. odd.

guessing that the "..." contained "#include <libc.h>" and trying a little test,
I find that probably the "name clashes" were (was?) probably singular:

/386/include/ape/float.h:43 yy.c:3 redeclare tag: FPdbleword

so now we know the problem, what to do about it?
i know an unpleasant way but perhaps someone else can think of a good way to get those
values outside the APE include files.  libc.h doesn't define equivalents.
perhaps the values aren't actually all that useful (i'm not sure how i'd use
them myself in a calculator, for instance).




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-06  8:06         ` Charles Forsyth
@ 2008-08-06 12:43           ` Pietro Gagliardi
  2008-08-06 12:59             ` erik quanstrom
  0 siblings, 1 reply; 11+ messages in thread
From: Pietro Gagliardi @ 2008-08-06 12:43 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Aug 6, 2008, at 4:06 AM, Charles Forsyth wrote:

>> My  program uses some of them (DBL_MIN, DBL_MAX, DBL_EPSILON), and
>> including <ape/float.h> yields name clashes. Thanks.
>
>> #include <u.h>
>> ...
>> #include <ape/float.h>
>
> it's surprisingly important not to leave out important information,
> such as
> what important things were in the "..." (other include files) and,
> most importantly, the particular "name clashes".
>
> i'd noticed you were using <ape/float.h> not <float.h> which i'd
> thought curious
> (were you mixing APE and Plan 9 include files?) but like most others
> i'd initially
> assumed the "name clashes" had to do with the DBL_ names. odd.
>

Yes. Plan 9 has no float.h of its own.

> guessing that the "..." contained "#include <libc.h>" and trying a
> little test,
> I find that probably the "name clashes" were (was?) probably singular:
>
> /386/include/ape/float.h:43 yy.c:3 redeclare tag: FPdbleword
>

The other is in <u.h>.

> so now we know the problem, what to do about it?
> i know an unpleasant way but perhaps someone else can think of a
> good way to get those
> values outside the APE include files.  libc.h doesn't define
> equivalents.
> perhaps the values aren't actually all that useful (i'm not sure how
> i'd use
> them myself in a calculator, for instance).
>
>

If your unpleasant way is to copy float.h, it won't work; you'll need
one for each $objtype. I found an algorithm to get epsilon, but not
min or max.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-06 12:43           ` Pietro Gagliardi
@ 2008-08-06 12:59             ` erik quanstrom
  0 siblings, 0 replies; 11+ messages in thread
From: erik quanstrom @ 2008-08-06 12:59 UTC (permalink / raw)
  To: pietro10, 9fans

> If your unpleasant way is to copy float.h, it won't work; you'll need
> one for each $objtype. I found an algorithm to get epsilon, but not
> min or max.
>

as far as i know, all plan 9 compilers use IEEE 754-compatable semantics
(at least insomuch as allowed by hardware).  thus the minima and maxima,
ε, and underflow properties depend on IEEE 754, not the processor.

/sys/doc/port.ps has the most complete information, but i would imagine
that the powerpc and arm information is slightly out-of-date.

- erik



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-06  3:22       ` Pietro Gagliardi
  2008-08-06  8:06         ` Charles Forsyth
@ 2008-08-06 16:29         ` Greg Comeau
  2008-08-07 18:24           ` Pietro Gagliardi
  1 sibling, 1 reply; 11+ messages in thread
From: Greg Comeau @ 2008-08-06 16:29 UTC (permalink / raw)
  To: 9fans

In article <A34E0AEF-930F-45D3-9E8C-E518998604C4@mac.com>,
Pietro Gagliardi <pietro10@mac.com> wrote:
>On Aug 5, 2008, at 11:14 PM, ron minnich wrote:
>
>> I'm so confused. Why don't you just show the code.
>>
>> ron
>>
>
>#include <u.h>
>...
>#include <ape/float.h>
>...
>
>static struct{
>	char *name;
>	double value;
>}constants[] = {
>	...
>	"MIN",		DBL_MIN,
>	"MAX",		DBL_MAX,
>	"EPSILON",	DBL_EPSILON,
>	...
>};
>
>I'm actually writing a calculator that will take advantage of several
>features of Plan 9 (Runes, libgeometry, etc.) and I'd like to make
>these available.

Does it help any to initialize constants[] in a source file
by itself?
--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==>     http://www.comeaucomputing.com/tryitout
World Class Compilers:  Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-06 16:29         ` Greg Comeau
@ 2008-08-07 18:24           ` Pietro Gagliardi
  2008-08-07 19:49             ` Federico G. Benavento
  0 siblings, 1 reply; 11+ messages in thread
From: Pietro Gagliardi @ 2008-08-07 18:24 UTC (permalink / raw)
  To: comeau, Fans of the OS Plan 9 from Bell Labs

On Aug 6, 2008, at 12:29 PM, Greg Comeau wrote:

> Does it help any to initialize constants[] in a source file
> by itself?

I don't know, but your idea gave me something that did:

% cat mach.c
#include <ape/float.h>

double dblmin = DBL_MIN;
double dblmax = DBL_MAX;
double dbleps = DBL_EPS;
% cat builtins.c
...
	extern double dblmin, dblmax, dbleps;
...
	install(s_copy("MIN"), CONSTANT, dblmin);
	install(s_copy("MAX"), CONSTANT, dblmax);
	install(s_copy("EPSILON"), CONSTANT, dbleps);
...




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9fans] float.h
  2008-08-07 18:24           ` Pietro Gagliardi
@ 2008-08-07 19:49             ` Federico G. Benavento
  0 siblings, 0 replies; 11+ messages in thread
From: Federico G. Benavento @ 2008-08-07 19:49 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

why are you including <ape/float.h> ?

you're lucky that /$objtype/include/ape/float.h doesn't have
a #pragma lib, otherwise you'll be seeing some weird behavior.

you should not link APE's libs against the standard libc.

On Thu, Aug 7, 2008 at 3:24 PM, Pietro Gagliardi <pietro10@mac.com> wrote:
> On Aug 6, 2008, at 12:29 PM, Greg Comeau wrote:
>
>> Does it help any to initialize constants[] in a source file
>> by itself?
>
> I don't know, but your idea gave me something that did:
>
> % cat mach.c
> #include <ape/float.h>
>
> double dblmin = DBL_MIN;
> double dblmax = DBL_MAX;
> double dbleps = DBL_EPS;
> % cat builtins.c
> ...
>        extern double dblmin, dblmax, dbleps;
> ...
>        install(s_copy("MIN"), CONSTANT, dblmin);
>        install(s_copy("MAX"), CONSTANT, dblmax);
>        install(s_copy("EPSILON"), CONSTANT, dbleps);
> ...
>
>
>



--
Federico G. Benavento



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-08-07 19:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-05 19:07 [9fans] float.h Pietro Gagliardi
2008-08-05 23:43 ` Russ Cox
2008-08-06  2:51   ` Pietro Gagliardi
2008-08-06  3:14     ` ron minnich
2008-08-06  3:22       ` Pietro Gagliardi
2008-08-06  8:06         ` Charles Forsyth
2008-08-06 12:43           ` Pietro Gagliardi
2008-08-06 12:59             ` erik quanstrom
2008-08-06 16:29         ` Greg Comeau
2008-08-07 18:24           ` Pietro Gagliardi
2008-08-07 19:49             ` Federico G. Benavento

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).