Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Mar 2001 12:28:01 +0200
From:      Peter Pentchev <roam@orbitel.bg>
To:        G Hasse <gh@raditex.se>
Cc:        dwmalone@FreeBSD.org, freebsd-bugs@FreeBSD.org
Subject:   Re: misc/25904: Error in the printf-function.
Message-ID:  <20010319122801.D515@ringworld.oblivion.bg>
In-Reply-To: <Pine.BSF.4.21.0103191113530.12867-100000@gandalf.sickla.raditex.se>; from gh@raditex.se on Mon, Mar 19, 2001 at 11:15:43AM %2B0100
References:  <200103191005.f2JA51r98657@freefall.freebsd.org> <Pine.BSF.4.21.0103191113530.12867-100000@gandalf.sickla.raditex.se>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Mar 19, 2001 at 11:15:43AM +0100, G Hasse wrote:
> On Mon, 19 Mar 2001 dwmalone@FreeBSD.org wrote:
> 
> > Synopsis: Error in the printf-function.
> > 
> > State-Changed-From-To: open->closed
> > State-Changed-By: dwmalone
> > State-Changed-When: Mon Mar 19 02:04:13 PST 2001
> > State-Changed-Why: 
> > Seems to be due to misues of printf.
> 
> In Linux printf I get this printout...
> 
>   Var is 2.256102   /* an address printed as float. Stupid! but the
> Value is 2.400000      way to print an float adress? */
>   Var is 2.256102 
> Value is 4 
>   Var is 4 
> 
> So way is the conversion of an address in FreeBSD 0?

To print a pointer, you use printf("%p", ptr).  To print a float
variable, you use printf("%f", var).  To print a float value, which
hangs at the end of a pointer to a float, you must first dereference
the pointer, and pass the value to printf() as a simple float:

	float v, *p;

	v = 2.5;
	p = &v;
	printf("v is %f, p is %p, *p is %f\n", v, p, *p);

G'luck,
Peter

-- 
If wishes were fishes, the antecedent of this conditional would be true.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010319122801.D515>