此表达式如何工作? ($ variable / 60)%60

时间:2019-04-10 15:25:43

标签: php modulus

我了解模量是如何工作的。它给出了数字的其余部分。所以482%60会给2。

有人可以向我解释一下这种表达吗?

GeomLink <- ggplot2::ggproto("GeomLink", ggplot2::GeomCurve,
                             required_aes = c("id", "x", "y", "from", "to", "polarity", "type", "group"),
                             default_aes = ggplot2::aes(id = id, x = x, y = y, xend = x, yend = y, from = from, to = to, polarity = polarity, type = type, group = group, colour = "black",
                                                        size = 4, angle = 0, hjust = 0.5, vjust = 0.5,
                                                        alpha = NA, fontface = 1,
                                                        lineheight = 1.2, length = 10),
                             setup_data = function(data, params){
                               data <- link_coordinates(data)
                               data <- data[data$type == "link", ]
                               print(data)
                             })


geom_link <- function(mapping = ggplot2::aes(x = from_x, y = from_y, xend = to_x, yend = to_y, id = id, from = from, to = to, polarity = polarity, type = type), data = NULL, position = "identity", stat = "identity",
                      ..., curvature = 0.2, angle = 90, ncp = 5, arrow = NULL,
                      arrow.fill = NULL, lineend = "butt", na.rm = FALSE, show.legend = NA,
                      inherit.aes = TRUE)
{
  ggplot2::layer(data = data, mapping = mapping, stat = stat, geom = GeomLink,
                 position = position, show.legend = show.legend, inherit.aes = inherit.aes,
                 params = list(arrow = arrow, arrow.fill = arrow.fill,
                               curvature = curvature, angle = angle, ncp = ncp,
                               lineend = lineend, na.rm = na.rm, ...))
}

对我来说,这说:

$minutes = ($seconds/60) % 60;

然后得出的结果是8。对我来说,省略%60部分并将482/60设为整数会更简单。而且我不了解%60在这种情况下的运行方式。

我想念什么?

2 个答案:

答案 0 :(得分:2)

它为您提供分钟没有时间的时间。您的示例没有说明这一点,因为您使用的秒数<3600。

4000 seconds:
(seconds/60)%60
(4000/60)%60
(66.666)%60
结果是

6分钟。 1小时是由另一个公式计算的,最值得注意的是秒/ 3600。

答案 1 :(得分:1)

考虑秒是否是3661。您将有一个小时,一分钟,一秒。您的公式的分钟数为61。