In fit_field_base.cpp, the FieldBase::SetFLOAT64Value method uses C-style casts to convert a FIT_FLOAT64 (i.e. double) value to an unsigned integer. For fields with a signed type, the conversion is not standard, especially if the roundedValue is negative.
For instance, the type of the "grade" field is FIT_BASE_TYPE_SINT16. According to the following snippet, roundedValue (double) is being converted to a FIT_UINT16 (i.e. uint16_t):
This works well when roundedValue is positive. However, the result of the conversion is implementation-dependent when roundedValue is negative. On some platforms, casting a negative double to an unsigned integer amounts to 0. A possible solution for this could be using the SetSINT16Value method for fields with a signed type: