]> foleosoft.com Git - QAnsel.git/commitdiff
Mon Feb 12 02:26:18 PM EST 2024
authormiha-q <>
Mon, 12 Feb 2024 19:26:18 +0000 (14:26 -0500)
committermiha-q <>
Mon, 12 Feb 2024 19:26:18 +0000 (14:26 -0500)
src/QAnsel.c

index 98aa7e00f4ee391914e14e8c10357ef2522fcc95..6ee32a6f08d1b026f95a6d2eb9a69527ab1413b7 100644 (file)
@@ -429,7 +429,7 @@ void qansel_run(uint8_t qubitCount, uint8_t bitCount, QInstr* instr, uint8_t* re
                                }
                                cpx_t n;
                                cpx_mtx_get(&stateVector, 0, j, &n);
-                               printf(": %.00f%%\n", cpx_magsqr(&n) * 100);
+                               printf(": %.2f%%\n", cpx_magsqr(&n) * 100);
                        }
                }
                else if (strcmp(instr[i].n, "born") == 0)
@@ -444,8 +444,8 @@ void qansel_run(uint8_t qubitCount, uint8_t bitCount, QInstr* instr, uint8_t* re
                                        prob += cpx_magsqr(&n);
                                }
                        }
-                       printf("0: %.00f%%\n", (1 - prob) * 100.0);
-                       printf("1: %.00f%%\n", prob * 100.0);
+                       printf("0: %.2f%%\n", (1 - prob) * 100.0);
+                       printf("1: %.2f%%\n", prob * 100.0);
                }
                else if (strcmp(instr[i].n, "hvar") == 0)
                {
@@ -1321,14 +1321,14 @@ void process(int argc, char** argv)
                        }
                        if (fullSample == 255)
                        {
-                               printf(": %.00f%%\n", ((double)stats[i] / (double)shots) * (double)100);
+                               printf(": %.2f%%\n", ((double)stats[i] / (double)shots) * (double)100);
                        }
                }
                if (fullSample != 255)
                {
                        double prob = ((double)count / (double)shots) * (double)100;
-                       printf("0: %.00f%%\n", ((double)100)-prob);
-                       printf("1: %.00f%%\n", prob);
+                       printf("0: %.2f%%\n", ((double)100)-prob);
+                       printf("1: %.2f%%\n", prob);
                }
        }
        else