# Is there any way to make the CKKS ciphertext difference an integer

**URL:** https://openfhe.discourse.group/t/is-there-any-way-to-make-the-ckks-ciphertext-difference-an-integer/1691
**Category:** Library Questions
**Created:** [November 5, 2024, 2:11pm UTC](https://openfhe.discourse.group/t/is-there-any-way-to-make-the-ckks-ciphertext-difference-an-integer/1691 "2024-11-05T14:11:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![capibala](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@capibala](https://openfhe.discourse.group/u/capibala)
#### Post date: [November 5, 2024, 2:11pm UTC](https://openfhe.discourse.group/t/is-there-any-way-to-make-the-ckks-ciphertext-difference-an-integer/1691/1 "2024-11-05T14:11:16Z")

</div>

In the project example, after subtracting two CKKS ciphertexts, EvalSign is executed and then packaged back to the CKKS ciphertext,which is not strictly encrypted 0/1 but approximate value, is there any way to make the approximate value become 0/1?

 ![屏幕截图 2024-11-05 221036](https://canada1.discourse-cdn.com/flex031/uploads/openfhe/original/1X/ab78ec4bf836e7c2a817c4ae43ad6850b8d6e14f.png)

---

<div class="post-metadata">

### Author: ![seyda](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/seyda/32/397_2.png) [@seyda](https://openfhe.discourse.group/u/seyda)
#### Post date: [November 5, 2024, 3:14pm UTC](https://openfhe.discourse.group/t/is-there-any-way-to-make-the-ckks-ciphertext-difference-an-integer/1691/2 "2024-11-05T15:14:21Z")

</div>

Do you mean, rounding as a post-processing? Or do you mean if we can make the CKKS output integers? If latter, why don’t you consider using exact arithmetic word-wise schemes BGV/BFV to work with integers?  
CKKS is an approximate scheme and allows working on complex numbers. A ciphertext has no information regarding the input (being an integer or real number), so the decryption step is only calculating the inner product of the secret key and the ciphertext. An output of 0.999 is as valid as 1.000, as both are real numbers.

---

<div class="post-metadata">

### Author: ![capibala](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@capibala](https://openfhe.discourse.group/u/capibala)
#### Post date: [November 6, 2024, 1:49am UTC](https://openfhe.discourse.group/t/is-there-any-way-to-make-the-ckks-ciphertext-difference-an-integer/1691/3 "2024-11-06T01:49:20Z")

</div>

Because my 0/1 ciphertext is obtained by executing CKKS-\>TFHE-\>EvalSign-\>CKKS, BGV/BFV does not support Scheme switching

---

<div class="post-metadata">

### Author: ![capibala](https://avatars.discourse-cdn.com/v4/letter/c/b5ac83/32.png) [@capibala](https://openfhe.discourse.group/u/capibala)
#### Post date: [November 6, 2024, 1:52am UTC](https://openfhe.discourse.group/t/is-there-any-way-to-make-the-ckks-ciphertext-difference-an-integer/1691/4 "2024-11-06T01:52:49Z")

</div>

And many advanced functions such as Sum and Min are only available for CKKS

---

<div class="post-metadata">

### Author: ![andreea.alexandru](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/andreea.alexandru/32/378_2.png) [@andreea.alexandru](https://openfhe.discourse.group/u/andreea.alexandru)
#### Post date: [November 6, 2024, 5:14pm UTC](https://openfhe.discourse.group/t/is-there-any-way-to-make-the-ckks-ciphertext-difference-an-integer/1691/5 "2024-11-06T17:14:46Z")

</div>

In CKKS, the error (which is never precisely zero) corrupts the message, which is why even after only encoding 1, encrypting it and then decrypting it, you may get 0.99999. Even if you apply a homomorphic rounding procedure, you will still get such results. If you switch the scheme, for instance to FHEW, a rounding takes place and this is how you obtain integers. So, in short, the current CKKS scheme implementation works with real numbers (fixed point), and if you want (small) integers, you can switch to FHEW.
