From 87510bcb2498531155b5c389219704ff554be400 Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Sat, 4 May 2024 20:08:14 -0500 Subject: [PATCH] manage floating values --- partition-before-pggb | 8 ++++++-- pggb | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/partition-before-pggb b/partition-before-pggb index 009df06..53c3c5f 100755 --- a/partition-before-pggb +++ b/partition-before-pggb @@ -347,9 +347,13 @@ if [[ $block_length == false ]]; then fi if [[ $hg_filter_ani_diff == false ]]; then - if [[ $map_pct_id -ge 90 ]]; then + # Convert map_pct_id to a format that bc can handle if it's not already a decimal + map_pct_id_decimal=$(printf "%.2f" "$map_pct_id") + + # Using bc for floating-point comparison + if [[ $(echo "$map_pct_id_decimal >= 90" | bc) -eq 1 ]]; then hg_filter_ani_diff=30 - elif [[ $map_pct_id -lt 90 && $map_pct_id -ge 80 ]]; then + elif [[ $(echo "$map_pct_id_decimal >= 80 && $map_pct_id_decimal < 90" | bc) -eq 1 ]]; then hg_filter_ani_diff=10 else hg_filter_ani_diff=0 diff --git a/pggb b/pggb index a77a59a..290621e 100755 --- a/pggb +++ b/pggb @@ -347,9 +347,13 @@ if [[ $block_length == false ]]; then fi if [[ $hg_filter_ani_diff == false ]]; then - if [[ $map_pct_id -ge 90 ]]; then + # Convert map_pct_id to a format that bc can handle if it's not already a decimal + map_pct_id_decimal=$(printf "%.2f" "$map_pct_id") + + # Using bc for floating-point comparison + if [[ $(echo "$map_pct_id_decimal >= 90" | bc) -eq 1 ]]; then hg_filter_ani_diff=30 - elif [[ $map_pct_id -lt 90 && $map_pct_id -ge 80 ]]; then + elif [[ $(echo "$map_pct_id_decimal >= 80 && $map_pct_id_decimal < 90" | bc) -eq 1 ]]; then hg_filter_ani_diff=10 else hg_filter_ani_diff=0