Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- sequence=(
- 0.9311600617849973
- 0.3551442693830502
- 0.7923158995678377
- 0.787777942408997
- 0.376372264303491
- )
- sequence=($(echo "${sequence[@]}" | tac))
- for ((i=${#sequence[@]}-1; i>=0; i--)); do
- se_s1=$se_state0
- se_s0=$se_state1
- se_state0=$se_s0
- se_s1=$((se_s1 ^ (se_s1 << 23)))
- se_s1=$((se_s1 ^ (se_s1 >> 17)))
- se_s1=$((se_s1 ^ se_s0))
- se_s1=$((se_s1 ^ (se_s0 >> 26)))
- se_state1=$se_s1
- float_64=$(echo "${sequence[i]} + 1" | awk '{print $1}')
- u_long_long_64=$(python -c "import struct; print(struct.unpack('<Q', struct.pack('d', $float_64))[0])")
- mantissa=$((u_long_long_64 & ((1 << 52) - 1)))
- if [ $mantissa -eq $((se_state0 >> 12)) ]; then
- echo "Mantissa match found at index $i"
- state0=$se_state0
- u_long_long_64=$((state0 >> 12 | 0x3FF0000000000000))
- float_64=$(python -c "import struct; print(struct.unpack('d', struct.pack('<Q', $u_long_long_64))[0])")
- next_sequence=$(echo "$float_64 - 1" | awk '{print $1}')
- echo "Next sequence: $next_sequence"
- exit 0
- fi
- done
- echo "No match found"
- exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement