From 228258221ca9d8eb30e36b39f5b2fa0147b3e1af Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 10 May 2024 22:05:15 +0200 Subject: [PATCH] initialize all res in power to 1 --- lab3/zad1/include/DHSetup.hpp | 2 +- lab3/zad2/app/src/main/java/pl/jacekpoz/DHSetup.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lab3/zad1/include/DHSetup.hpp b/lab3/zad1/include/DHSetup.hpp index 2c08c54..d31f437 100644 --- a/lab3/zad1/include/DHSetup.hpp +++ b/lab3/zad1/include/DHSetup.hpp @@ -59,7 +59,7 @@ public: } T power(T a, uint64_t b) { - T res = a; + T res = 1; while (b > 0) { if (b % 2 == 1) { res *= a; diff --git a/lab3/zad2/app/src/main/java/pl/jacekpoz/DHSetup.java b/lab3/zad2/app/src/main/java/pl/jacekpoz/DHSetup.java index a65497f..1074d1c 100644 --- a/lab3/zad2/app/src/main/java/pl/jacekpoz/DHSetup.java +++ b/lab3/zad2/app/src/main/java/pl/jacekpoz/DHSetup.java @@ -74,7 +74,7 @@ public class DHSetup implements IDHSetup { @Override public T power(final T a, long b) { T aCopy = this.constructor.apply(new GF.Params(a.getCharacteristic(), a.getValue())); - T res = this.constructor.apply(new GF.Params(a.getCharacteristic(), a.getValue())); + T res = this.constructor.apply(new GF.Params(a.getCharacteristic(), 1)); while (b > 0) { if (b % 2 == 1) { res.multiplyAssign(aCopy);