Re: Summation, modulo and decimal



In article <1138051905.570033.233690@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<spin9@xxxxxxxxxxxx> wrote:
>Hello.
>
>I'm trying to use the modulo (modulus, mod, %) to do the following:
>
>(1) 0,147536 -> (2) 0.101110
>
>The problem is that modulo is only def. to Integers.

Indeed. What is it you expect the answer to be? Are you looking for
the unique real number m such that

0.147536 = p*0.101110 + m

such that p is an integer and 0<= m < 0.101110 ?

> So, I used the
>sigma/summation to shift the decimal point to the left (multiply by
>10^k) to get each digit. It not worked because before it shift the
>digit to the left the number is added to the previous value, so, I used
> in the formula another "trick" (-1)^k , so the number stay the same
>after k even increments. When I try to use it all together the (-1)^k
>and the 10^k "cancel each other" and I get the same initial value.
>What=B4s wrong with my logic?

Yikes. What is it you are doing, explicitly?


The easiest way to do what you want, if what I think you want is
indeed what you want, is to simply multiply both numbers by 10^6, do
the modulus, and then divide the result by 10^6. That is, do 147536
mod 101110, which is 46426; then divide the result by 10^6 to get
0.046426

>How can I use the Sum and Mod to turn each number to 1=B4s and 0=B4s
>giving a number, say, 3,14231243545546 ?

Huh?


--
======================================================================
"It's not denial. I'm just very selective about
what I accept as reality."
--- Calvin ("Calvin and Hobbes")
======================================================================

Arturo Magidin
magidin@xxxxxxxxxxxxxxxxx

.



Relevant Pages

  • Summation, modulo and decimal
    ... The problem is that modulo is only def. ... It not worked because before it shift the ... digit to the left the number is added to the previous value, so, I used ...
    (sci.math)
  • Re: Rabin vs. RSA/ElGamal
    ... roots for me modulo your modulus, ... But then, so is "raw RSA". ... permutation into a full-blown public-key encryption scheme. ... or cubing modulo N -- a building block, not something it makes sense to ...
    (sci.crypt)
  • boolean function problem.
    ... way to do this is to store the weights in an array: ... In our example 11-5=6 therefore the check digit is 6. ... The last element in the customer code array must be checked against the results ... Here are some examples of using the modulus 11 to test the check digit:- ...
    (comp.lang.cpp)
  • Re: Is there any COBOL program for verify the SSN?
    ... Modulus 11 is NOT the same as Modulo 11. ... The Luhn algorithm or Luhn formula, also known as the "modulus 10" or "mod 10" algorithm, is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers and Canadian Social Insurance Numbers. ...
    (comp.lang.cobol)
  • Re: [QUIZ] Modular Arithmetic (#179)
    ... one less than the modulus. ... we must use the appropriate congruent value modulo 24. ... While most operations will be straightforward, modular division is a ... def coerce ...
    (comp.lang.ruby)