comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: -0.0
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: -0.0 [message #74555 is a reply to message #74553] Thu, 20 January 2011 11:16 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paolo writes:

> This falls into the "sky is falling" category, although with
> a slight different twist.
>
> http://www.dfanning.com/math_tips/sky_is_falling.html
>
> Signed zeros are allowed in the IEEE 754 standard for floating point
> arithmetic.
>
> IDL> print,-2.0*0
> -0.00000
> IDL> print,2.0*0
> 0.00000
>
> If you don't like that in the plot (and I agree that it looks ugly),
> you should
> manually change that tick label using the xtickname keyword.
>
> However, that is painful to do, so you could try the following hack:
>
> xrange=[-0.6,0.6]
> plot,[0,0],/nodata,/xstyle,xrange=xrange,title='this looks bad'
>
> ;workaround
> epsilon=1e-6
> xrange=[-0.6,0.6]
> xrange=xrange+epsilon*[-1,2]
> plot,[0,0],/nodata,/xstyle,xrange=xrange,title='better now'
>
>
> You see what happened there? Care to guess why it worked?

Here is another solution.

FUNCTION zeroAxis, axis, index, value

absvalue = Abs(value)
PRINT, value, absvalue, Format='(2(F0.8,2x))'
IF absvalue LT 0.001 THEN value = 0.0
IF value LT 0 THEN BEGIN
strValue = '-' + String(absvalue, Format='(F0.1)')
ENDIF ELSE BEGIN
strValue = String(absvalue, Format='(F0.1)')
ENDELSE

RETURN, strValue

END

x = -.6+indgen(13)*.1
plot, x, findgen(11), /nodata, $
xstyle=1, xtickformat='ZeroAxis'

END

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Crashes in IDL 7.1 & 8.0, interactive + VM mode, linux and Mac OS X
Next Topic: FSC_contour & NaN

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 02:46:35 PDT 2025

Total time taken to generate the page: 1.20313 seconds