Skip to content

Commit ceae5ee

Browse files
authored
Merge pull request TheAlgorithms#766 from abhijay94/Development
Cast the second operand of Math.pow to double - SonarQube analysis
2 parents d8bfa59 + 4456658 commit ceae5ee

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/com/crypto/codec/Base64.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static byte[] decodeBlock(byte[] block) {
184184

185185
decodedBlock[0] = (byte) (decodeAlphabet[block[0]] << 2 | decodeAlphabet[block[1]] >>> 4);
186186
decodedBlock[1] = (byte) (decodeAlphabet[block[1]] << 4 | decodeAlphabet[block[2]] >>> 2);
187-
decodedBlock[2] = (byte) (decodeAlphabet[block[2]] << 6 | decodeAlphabet[block[3]]);
187+
decodedBlock[2] = (byte) (decodeAlphabet[block[2]] << 6 | decodeAlphabet[block[3]] & 0xff);
188188

189189
return decodedBlock;
190190
}

src/main/java/com/generation/SimplexNoise.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public SimplexNoise(int largestFeature, double persistence, long seed) {
3636

3737
this.octaves[index] = new SimplexNoiseOctave(random.nextInt());
3838
this.frequencys[index] = Math.pow(2, index);
39-
this.amplitudes[index] = Math.pow(persistence, octaveCount - index);
39+
this.amplitudes[index] = Math.pow(persistence, (double) octaveCount - index);
4040
}
4141
}
4242

@@ -103,7 +103,7 @@ public double getNoise(int x, int y, int z) {
103103
for (int index = 0; index < this.octaves.length; index++) {
104104

105105
double frequency = Math.pow(2, index);
106-
double amplitude = Math.pow(this.persistance, this.octaves.length - index);
106+
double amplitude = Math.pow(this.persistance, (double) this.octaves.length - index);
107107

108108
result += this.octaves[index].noise(x / frequency, y / frequency, z / frequency) * amplitude;
109109
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy