https://www.growthbook.io/ logo
j

jolly-journalist-68574

08/21/2023, 8:02 PM
When creating a Feature where the Value Type is number, if I set the value to be
1.0
it still saves it as
intValue
instead of
doubleValue
. If I set the value to be
1.01
it saves it as
doubleValue
. Is there any way to set the number Value Type to be
doubleValue
for a value of
1
or
1.0
?
b

better-magician-65629

08/21/2023, 9:03 PM
hey vincent, are you talking about saving it in the dashboard somewhere? where are you seeing the results as an int value instead of a double? is this related to any of the SDK's or the growthbook dashboard?
j

jolly-journalist-68574

08/21/2023, 10:20 PM
Hi Tina, I'm talking about the values saved in the Features tab of the GrowthBook web UI. I see them returned as INT values from the GrowthBook SDK
b

better-magician-65629

08/21/2023, 10:22 PM
thanks for clarifying. we do have a team member looking into this right now and can confirm the issue you describe. while it doesn't look ideal, when using it in an SDK, it should not present a problem, it's just not ideal to see the wrong precision in the UI. cc @happy-autumn-40938
j

jolly-journalist-68574

08/21/2023, 10:24 PM
I want to say that the UI was actually displaying it correctly as
1.0
, but the SDK was returning the INT value of
1
h

happy-autumn-40938

08/21/2023, 10:26 PM
to be clear, we're talking about the value applied (forced), not the rule used to evaluate?
b

better-magician-65629

08/21/2023, 10:26 PM
in our SDK's that are in languages that are not strictly typed, i imagine this will be an issue. i'm guessing you're using either JS, ruby or python? please confirm
j

jolly-journalist-68574

08/21/2023, 10:27 PM
I'm talking about this Default value here and the Forced Value:
I believe we are using the C# SDK
b

better-magician-65629

08/21/2023, 10:33 PM
might be worth it for us to create a ticket @happy-autumn-40938 to not coerce float values to integers in the JSON generator section we were talking about. it's likely to cause an issue in numerous SDKs
h

happy-autumn-40938

08/21/2023, 10:36 PM
b

better-magician-65629

08/21/2023, 10:37 PM
@jolly-journalist-68574 as a workaround, it might make sense to format the number in your view with the required level of precision instead of relying on the evaluated value
j

jolly-journalist-68574

08/22/2023, 11:36 PM
Thank you for the ticket. @better-magician-65629 I'm not quite sure what your last suggestion meant, could you elaborate? What did you mean by "format the number in your view"
h

happy-autumn-40938

08/22/2023, 11:47 PM
I think generally we're wondering whether you're able to coerce the evaluated flag value into the number format that your app requires (int, double, etc). Generally it would be best to have an opinionated type for this value within your app and not rely on the SDK payload format.
b

better-magician-65629

08/23/2023, 12:01 AM
the value that will be displayed to users. for example, if using javascript:
Copy code
const value = growthbook.getFeatureValue('my_float_value', 0) // => 1
const displayValue = value.toFixed(2) // => '1.00'
i'm looking at the C# SDK now, it looks like the
GetFeatureValue<T>()
method is genericized. can you pass in your desired type, e.g. Double, and how does it behave? this signature looks similar to the java SDK, and in java we coerce the value to the desired number type. wondering if the C# SDK behaves similarly.
i ddi further digging, it looks like it's implementing newstonsoft
JToken.ToObject<T>
and it should probably be coerced for you, similar to how i described the behaviour of the java SDK. https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Linq_JToken_ToObject__1.htm
can you clarify which C# SDK methods you're using?