Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tolerance applies in a surprising way to large integers #138

Open
Labels
featurea feature request or enhancement
@hadley

Description

@hadley
library(waldo)dt<- as.POSIXct("2016-07-18 16:06:00",tz="UTC")compare(dt,dt+5)#> `old`: "2016-07-18 16:06:00"#> `new`: "2016-07-18 16:06:05"compare(1468857960,1468857965)#> `old`: 1468857960#> `new`: 1468857965(tol<-testthat::testthat_tolerance())#> [1] 1.490116e-08compare(dt,dt+5,tolerance=tol)#> ✓ No differencescompare(1468857960,1468857965,tolerance=tol)#> ✓ No differences

Created on 2022-03-12 by thereprex package (v2.0.1)

Compared withall.equal() which has different behaviour for POSIXct:

library(waldo)dt<- as.POSIXct("2016-07-18 16:06:00",tz="UTC")all.equal(dt,dt+5)#> [1] "Mean absolute difference: 5"all.equal(1468857960,1468857965)#> [1] TRUE

Created on 2022-03-12 by thereprex package (v2.0.1)

I don't think the behaviour is correct in either case: the purpose of tolerance is to ignore minor differences that arise due to floating point error, not to ignore differences in integers that can be exactly represented in floating point.

cc@MichaelChirico

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp