* Adds a double to the current value. * */
| 868 | * |
| 869 | */ |
| 870 | static void |
| 871 | AddDoubleToValue(bson_value_t *current, double value) |
| 872 | { |
| 873 | /* If existing value is decimal128, then needs to convert the value to decimal128 */ |
| 874 | if (current->value_type == BSON_TYPE_DECIMAL128) |
| 875 | { |
| 876 | bson_value_t valueBson; |
| 877 | valueBson.value.v_double = value; |
| 878 | valueBson.value_type = BSON_TYPE_DOUBLE; |
| 879 | |
| 880 | /* Transform value into decimal128 format */ |
| 881 | valueBson.value.v_decimal128 = GetBsonValueAsDecimal128Quantized(&valueBson); |
| 882 | valueBson.value_type = BSON_TYPE_DECIMAL128; |
| 883 | |
| 884 | AddDecimal128Numbers(current, &valueBson, current); |
| 885 | } |
| 886 | else |
| 887 | { |
| 888 | /* We match protocol behavior, which doesn't coerce to decimal128 |
| 889 | * in case of overflow and just returns infinity which is the same |
| 890 | * behavior in C in case of double overflow. */ |
| 891 | double currentValue = BsonValueAsDouble(current); |
| 892 | current->value_type = BSON_TYPE_DOUBLE; |
| 893 | current->value.v_double = currentValue + value; |
| 894 | } |
| 895 | } |
| 896 | |
| 897 | |
| 898 | /** |
no test coverage detected