Displaying 20 results from an estimated 7000 matches similar to: "Modular Arithmetic Error?"
2009 Aug 01
5
incorrect result (41/10-1/10)%%1 (PR#13863)
Full_Name: jan hattendorf
Version: 2.9.0
OS: XP
Submission from: (NULL) (213.3.108.185)
I get an incorrect result for
(41/10-1/10)%%1
[1] 1
The error did not occur with other numbers than 41 (1, 11, 21, 31, 51, ...)
test <- rep(NA, 1000)
for(i in 1:1000){
test[i] <- i/10-1/10
}
test[test%%1==0]
2013 Mar 07
2
A==A false?
>
> as.numeric(ImpVol[1,5,57]) == 0.0001
[1] FALSE
>
> as.numeric(ImpVol[1,5,57])
[1] 1e-04
>
> 0.0001
[1] 1e-04
>
Any tips?
Thanks
Sean
R 2.15.3
windows 7
2010 Jul 29
1
precision of minus operation and if statments
Hi Everyone,
as part of a larger script, I need to insert the result of a simple minus
operation into an if statement.
I have noticed that the precision that appear on the screen is not the precision
in which R stores the result of the minus operation, and that this change alters
the result of the if statement. For example, when running this simple script:
> a=0.90
> b=0.95
>
2009 Feb 12
3
trunc/floor a number -- strange bahaviour
Hi everybody,
given a fresh rgui.exe load on winxp OS, I enter (a minimal exaple)
n <- 12.357531
Then the following command:
n <- (n - floor(n))*10; n
gives the following outputs:
[1] 3.57531
[1] 5.7531
[1] 7.531
[1] 5.31
[1] 3.1
[1] 1 === still as expected
[1] 10 === not expected, count with me: 1 - floor(1) is zero, times
10 gives 0, not 10!!!!
[1] 10 === should
2006 Nov 22
3
odd behaviour of %%?
Dear R Helpers,
I am trying to extract the modulus from divisions by a sequence of
fractions.
I noticed that %% seems to behave inconsistently (to my untutored eye),
thus:
> 0.1%%0.1
[1] 0
> 0.2%%0.1
[1] 0
> 0.3%%0.1
[1] 0.1
> 0.4%%0.1
[1] 0
> 0.5%%0.1
[1] 0.1
> 0.6%%0.1
[1] 0.1
> 0.7%%0.1
[1] 0.1
> 0.8%%0.1
[1] 0
> 0.9%%0.1
The modulus for 0.1, 0.2, 0.4 and 0.8 is
2008 Mar 03
7
help for the first poster- a simple question
Hi, there,
I cannot get accurate value for calculation.
for example:
ld<-sqrt(1*0.05*0.95*0.05*0.95)
0.05*0.95-ld=-6.938894e-18
0.05*0.95-ld==0 is False.
I met this problem in my program, how can I handle it. Thanks.
xj.
2013 Jan 30
3
arithmetic and logical operators
Why, in R, does (0.1 + 0.05) > 0.15 evaluate to True? What am I missing
here? How can I ensure this (ostensibly incorrect) behavior doesn't
introduce bugs into my code? Thanks for your time.
Dave Mitchell
[[alternative HTML version deleted]]
2017 May 24
1
precision of do_arith() in arithmetic.c
To the R development team:
First of all, thank you so much for maintaining wonderful R software.
Perhaps, Dr. Ahn has just reported an error on the wilcox.test() function,
and suggesting that an error may arise from abs() and rank().
I just had a quick check that the problem may come from the precision of
the results of arithmetic functions.
87.7-89.1+1.4
# > 87.7-89.1+1.4
# [1]
2008 Apr 24
2
problem with "which"
Hi,
I'm having trouble with the "which" or the "seq" function, I'm not sure.
Here's an example :
> lat=seq(1,2,by=0.1)
> lat
[1] 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0
> which(lat==1)
[1] 1
> which(lat==1.1)
[1] 2
> which(lat==1.2)
[1] 3
> which(lat==1.3)
[1] 4
> which(lat==1.4)
[1] 5
> which(lat==1.5)
[1] 6
>
2008 Dec 05
3
Logical inconsistency
Dear colleagues
Please could someone kindly explain the following inconsistencies I've discovered when performing logical calculations in R:
8.8 - 7.8 > 1
> TRUE
8.3 - 7.3 > 1
> TRUE
Thank you,
Emma Jane
[[alternative HTML version deleted]]
2017 Jun 07
3
An R question
Hi all,
In checking my R codes, I encountered the following problem. Is there a
way to fix this?
I tried to specify options(digits=). I did not fix the problem.
Thanks so much for your help!
Hanna
> cdf(pmass)[2,2]==pcum[2,2][1] FALSE> cdf(pmass)[2,2][1] 0.9999758> pcum[2,2][1] 0.9999758
[[alternative HTML version deleted]]
2010 Dec 20
6
sample() issue
> length(sample(25000, 25000*(1-.55)))
[1] 11249
> 25000*(1-.55)
[1] 11250
> length(sample(25000, 11250))
[1] 11250
> length(sample(25000, 25000*.45))
[1] 11250
So the question is, why do I get 11249 out of the first command and not
11250? I can't figure this one out.
Thanks
Cory
[[alternative HTML version deleted]]
2006 Jul 07
2
BUG in " == " ? (PR#9065)
Hello,
here is the version of R that I use :
> version
_
platform i486-pc-linux-gnu
arch i486
os linux-gnu
system i486, linux-gnu
status
major 2
minor 3.1
year 2006
month 06
day 01
svn rev 38247
language R
version.string Version 2.3.1 (2006-06-01)
And here is one of the sequences of
2009 Jun 08
4
seq(...) strange logical value
Do you heve any idea why I get after this instruction everywhere false?
> seq (0, 1, by=0.1) == 0.3
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
But after different step it's ok:
> seq(0, 1, by=0.1) == 0.4
[1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
--
View this message in context:
2008 Aug 07
3
Bug in rnorm? (PR#12016)
Full_Name: Paul Eckermann
Version: 2.7.1
OS: Windows XP Service Pack 2
Submission from: (NULL) (129.127.183.12)
This is the first time I have submitted a bug report, so apologies if I have not
followed the correct protocol.
If I enter
length(rnorm(100*.29))
it returns 28 rather than 29.
y<-(1:100)/100
z<-sapply(y,function(x) length(rnorm(x*100)))
z!=100*y
indicates that it has
2009 Sep 13
2
How can I get "predict.lm" results with manual calculations ? (a floating point problem)
Hello dear r-help group
I am turning for you for help with FAQ number 7.31: "Why doesn't R think
these numbers are equal?"
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
*My story* is this:
I wish to run many lm predictions and need to have them run fast.
Using predict.lm is relatively slow, so I tried having it run faster by
2013 Nov 15
0
[LLVMdev] Modular arithmetic processors
Hi,
My personal opinion: Just to be sure I understand what you're considering:
you want to write a backend that will produce optimized machine code for a
device with modular arithmetic instructions (not simulate such a device on
a standard CPU)? In which case, won't the same assumptions that are
embodied in the transformations for the case of unsigned 2's complement
arithmetic (in
2013 Nov 15
2
[LLVMdev] Modular arithmetic processors
I've been playing around with LLVM to write a backend for a rather "simple"
(co-)processor. Assume that only three arithmetic instructions exist: ADD
mod N, SUB mod N and MUL mod N. The modulus N is programmable and stored in
a register. No ordinary arithmetic instructions are available. The word
size is 256-bit.
In other words, the following function, b + c mod N, corresponds to
2012 Mar 02
0
[LLVMdev] General modular and multiprecision arithmetic
Hi,
I know there's been some talk about bignums already, this is similar to
it, but not exactly the same.
I'm currently using LLVM for my master thesis. The goal is to make a
compiler for zero-knowledge proofs of knowledge protocols. This compiler
should target embedded devices. There's a language called the protocol
implementation language in which these protocols should be
2013 Nov 18
1
[LLVMdev] Modular arithmetic processors
Thanks for your insightful suggestions.
Yes, I am programming for a real device that does modular arithmetic (and
only modular arithmetic). The modulus N is fixed during a single launch of
a program. One way I could also come up with is to simply use add i256 %a,
%b to represent a + b mod n, and let LLVM passes to reason about possible
optimizations. However these are not semantically identical