Commit 75bee9a8 authored by Antoine Lucas's avatar Antoine Lucas
Browse files

add logical operator

parent 973e93d4
......@@ -78,6 +78,29 @@ pow.bigz <- function(e1, e2,...) {
##' Inverse: inv(a,b) := (1 / a) (modulo b)
inv.bigz <- function(a,b,...) .Call(biginteger_inv,a,b)
"!.bigz" <- function(a) a == 0
## as.boolean(x): x != 0
"|.bigz" <- function(a,b) {
a1 = a != 0
b1 = b != 0
a1 | b1
}
"&.bigz" <- function(a,b) {
a1 = a != 0
b1 = b != 0
a1 & b1
}
"xor.bigz" <- function(a,b) {
a1 = a != 0
b1 = b != 0
xor(a1 , b1)
}
gcd <- function(a,b)
UseMethod("gcd")
gcd.default <- function(a,b) as.integer(gcd.bigz(a,b))
......
......@@ -407,3 +407,23 @@ prod.bigq <- function(..., na.rm = FALSE)
X <- c.bigq(...)
.Call(bigrational_prod, if(na.rm) X[!is.na(X)] else X)
}
"!.bigq" <- function(a) a == 0
"|.bigq" <- function(a,b) {
a1 = a != 0
b1 = b != 0
a1 | b1
}
"&.bigq" <- function(a,b) {
a1 = a != 0
b1 = b != 0
a1 & b1
}
"xor.bigq" <- function(a,b) {
a1 = a != 0
b1 = b != 0
xor(a1, b1)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment