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

Home » Public Forums » archive » GDL weirdness (bug?) with modulo command
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
GDL weirdness (bug?) with modulo command [message #88331] Tue, 15 April 2014 07:44 Go to next message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
I'm not sure if this is a bug or if I'm missing something and I know there's a fair few GDL users here.

I was using the mod command to get the remainder from a value and then fixing it to be an integer and I noticed that some of the values were wrong.

I looked into it a bit more and think I can summarise the issue as:

GDL> print, 200.0 mod 12
7.99999
GDL> print, 200D mod 12
8.0000000

i.e. if the variable is a float, the mod command doesn't return the integer that you expect it to. If it's a double then you get the expected answer.

Am I missing some subtlety here or is this a bug?
Re: GDL weirdness (bug?) with modulo command [message #88336 is a reply to message #88331] Tue, 15 April 2014 11:50 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Tuesday, April 15, 2014 10:44:33 AM UTC-4, rj...@le.ac.uk wrote:
> I'm not sure if this is a bug or if I'm missing something and I know there's a fair few GDL users here.
>
>
>
> I was using the mod command to get the remainder from a value and then fixing it to be an integer and I noticed that some of the values were wrong.
>
>
>
> I looked into it a bit more and think I can summarise the issue as:
>
>
>
> GDL> print, 200.0 mod 12
>
> 7.99999
>
> GDL> print, 200D mod 12
>
> 8.0000000
>
>
>
> i.e. if the variable is a float, the mod command doesn't return the integer that you expect it to. If it's a double then you get the expected answer.
>
>
>
> Am I missing some subtlety here or is this a bug?

This is probably the issue...
https://www.idlcoyote.com/math_tips/sky_is_falling.html
Re: GDL weirdness (bug?) with modulo command [message #88345 is a reply to message #88336] Wed, 16 April 2014 00:55 Go to previous messageGo to next message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
Yeah, that's why I posted here rather than submitting a GDL bug report. I thought it might be some subtlety like that which wasn't actually a bug. However, mod behaves as I'd expect in IDL and it's only GDL with this issue.

I think that points to a bug or dodgy implementation in GDL...?

Cheers

On Tuesday, April 15, 2014 7:50:22 PM UTC+1, Craig Markwardt wrote:
>
> This is probably the issue...
>
> https://www.idlcoyote.com/math_tips/sky_is_falling.html
Re: GDL weirdness (bug?) with modulo command [message #88348 is a reply to message #88336] Wed, 16 April 2014 03:32 Go to previous messageGo to next message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
I forgot to say that it works as expected in IDL so if it is a precision thing then it's due to a different implementation in GDL. Not sure if that's down to a bug or not though..?


On Tuesday, April 15, 2014 7:50:22 PM UTC+1, Craig Markwardt wrote:
> On Tuesday, April 15, 2014 10:44:33 AM UTC-4, rj...@le.ac.uk wrote:
>
> This is probably the issue...
>
> https://www.idlcoyote.com/math_tips/sky_is_falling.html
Re: GDL weirdness (bug?) with modulo command [message #88357 is a reply to message #88345] Wed, 16 April 2014 12:14 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Wednesday, April 16, 2014 3:55:15 AM UTC-4, rj...@le.ac.uk wrote:
> Yeah, that's why I posted here rather than submitting a GDL bug report. I thought it might be some subtlety like that which wasn't actually a bug. However, mod behaves as I'd expect in IDL and it's only GDL with this issue.
>
>
>
> I think that points to a bug or dodgy implementation in GDL...?

Let's use your example.

print, (200.0 MOD 12) - 8.0

On IDL the result is 0.0. I agree, that's the expected value, because floating point should be able to calculate this exactly. But I would also argue that any value within 0 +/- EPS is consistent with 0.

Craig

EPS = (machar()).eps
Re: GDL weirdness (bug?) with modulo command [message #88456 is a reply to message #88331] Tue, 29 April 2014 02:17 Go to previous messageGo to next message
Alain Coulais is currently offline  Alain Coulais
Messages: 20
Registered: July 2010
Junior Member
> Am I missing some subtlety here or is this a bug?

Thank you for reporting it, it is now solved in the CVS.

Please report bugs also to GDL bugs tracker:
https://sourceforge.net/p/gnudatalanguage/bugs/
(sorry but anonymous report is deactivated due to spams ...)

Alain
Re: GDL weirdness (bug?) with modulo command [message #88533 is a reply to message #88456] Thu, 08 May 2014 13:36 Go to previous message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
On Tuesday, April 29, 2014 10:17:21 AM UTC+1, alai...@gmail.com wrote:
>
>
> Thank you for reporting it, it is now solved in the CVS.
>
>
>
> Please report bugs also to GDL bugs tracker:
>
> https://sourceforge.net/p/gnudatalanguage/bugs/
>
> (sorry but anonymous report is deactivated due to spams ...)
>
>
>
> Alain

That's excellent, thanks.

I didn't realise that the bug-tracker was being so actively monitored.

I've also reported another bug (I think?) which we found with INTERPOL.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Assigning the values of a matrix to a larger matrix
Next Topic: Contour labels not aligned with contours

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

Current Time: Wed Oct 08 15:07:47 PDT 2025

Total time taken to generate the page: 0.00482 seconds