round_decimal_places method

IcpTokens round_decimal_places(
  1. int round_decimal_places
)

Implementation

IcpTokens round_decimal_places(int round_decimal_places) {
    //print('icp without round: $this');
    List<String> icp_string_split = this.toString().split('.');
    if (icp_string_split.length <= 1) {
        return this;
    }
    String decimal_places_string = icp_string_split[1];
    if (round_decimal_places >= decimal_places_string.length) {
        return this;
    }
    String decimal_places_split_at_round = decimal_places_string.substring(0, round_decimal_places);
    return IcpTokens.of_the_double_string('${icp_string_split[0]}.${decimal_places_split_at_round}');
}