Acknowledged
CIQQA-3115

bug: System.getSystemStats().battery is Number instead of Float

According to the docs: Toybox.System.Stats.battery as Float, but on real fr965 it is a Number or at least it's value is always a Number (without decimal).

function initialize() {
    session = ActivityRecording.createSession({
	 	:name => "test",
	 	:sport => Activity.Sport.SPORT_RUNNING,
	 	:subSport => Activity.SubSport.SUB_SPORT_TREADMILL
	});
    batteryPercentageField = session.createField("battery", 11, FitContributor.DATA_TYPE_FLOAT, { :mesgType => FitContributor.MESG_TYPE_RECORD, :units => "%" });
}

function compute() as Void {
    batteryPercentageField.setData(System.getSystemStats().battery);
}

Parents
  • > According to the docs: Toybox.System.Stats.battery as Float, but on real fr965 it is a Number or at least it's value is always a Number (without decimal).

    "or at least it's value is always a Number (without decimal)."

    I think you mean "or at least its value is always an integer (or whole number)"

    To be clear there are two possibilities here:

    - SystemStats.battery is not being returned as a literal Float type (i.e. instanceof Float != true), but instead as a Number (or less likely, a Long). I think this is what you meant by "it is a Number" (referring to the literal type)

    - System.Stats.battery is actually being returned as a literal Float type, but its value is always an integer (or whole number). I think this is what you meant by "it's value is always a Number (without decimal)."

    One statement refers to the object type (where Number or Float are relevant types), while the other statement refers to a property of the value itself (e.g. whether or not the fractional part is ever non-zero)

    I know you know all that, but in context, "or at least it's value is always a Number (without decimal)" is not precise writing (specifically, the use of "Number" isn't correct here).

Comment
  • > According to the docs: Toybox.System.Stats.battery as Float, but on real fr965 it is a Number or at least it's value is always a Number (without decimal).

    "or at least it's value is always a Number (without decimal)."

    I think you mean "or at least its value is always an integer (or whole number)"

    To be clear there are two possibilities here:

    - SystemStats.battery is not being returned as a literal Float type (i.e. instanceof Float != true), but instead as a Number (or less likely, a Long). I think this is what you meant by "it is a Number" (referring to the literal type)

    - System.Stats.battery is actually being returned as a literal Float type, but its value is always an integer (or whole number). I think this is what you meant by "it's value is always a Number (without decimal)."

    One statement refers to the object type (where Number or Float are relevant types), while the other statement refers to a property of the value itself (e.g. whether or not the fractional part is ever non-zero)

    I know you know all that, but in context, "or at least it's value is always a Number (without decimal)" is not precise writing (specifically, the use of "Number" isn't correct here).

Children
  • Yes, I messed up with this sentence. What I actually meant was that the value I see is always a whole number. I haven't checked the type. Fortunately my code already is written in a way that it doesn't care if it's type is Number or Float.