Skip to content

Weird behaviour of DataSeries>>#closeTo: #208

Description

@Joshua-Dias-Barreto
ds:= DataSeries withKeys: #(1 2 3 4) values:#(1 10 2 3)  name:2 .
ds1:= DataSeries withKeys: #(1 2 3 4) values:#(1.0001 10 2 3)  name:2 .
ds closeTo: ds1.

Returns true

ds:= DataSeries withKeys: #(1 2 3 4) values:#(5 10 2 3)  name:2 .
ds1:= DataSeries withKeys: #(1 2 3 4) values:#(5.0001 10 2 3)  name:2 .
ds closeTo: ds1.

Also returns true.
However,

ds:= DataSeries withKeys: #(1 2 3 4) values:#(2 10 2 3)  name:2 .
ds1:= DataSeries withKeys: #(1 2 3 4) values:#(2.0001 10 2 3)  name:2 .
ds closeTo: ds1.

Returns false.

With certain numbers, it allows the default precision of 0.0001 ( 1, 4.....31, 256.......2047, 8192.....16383 )
And with the other numbers, it returns false.

This code can be used to see at which numbers it returns true ( set the range accordingly, the current range is 1 to 100):

ds:= DataSeries withKeys: #(1 2 3 4) values:#(1 10 2 3)  name:2 .
ds1:= DataSeries withKeys: #(1 2 3 4) values:#(1 10 2 3)  name:2 .
1 to: 100 do: [ :x |
	ds at: 1 put: x.
	ds1 at: 1 put: x + 0.0001.
	(ds closeTo: ds1) = true ifTrue: [ Transcript crShow: x ] ].

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions