Inconsistent decimal separator in st.number_input

Summary

There are some inconsistencies in displaying floats in st.number_input. Floats with two decimal places are displayed as ‘X,XX’ whereas floats with one decimal places are displayed as ‘X.X’. I tried to set the number format to “%0.2f”, but this did not change the issue.

Steps to reproduce

import streamlit as st
 
st.set_page_config(
    page_title="Test",
    page_icon=":clipboard:",
)

st.title('test')
st.sidebar.title('Test.')



with st.sidebar:

    test = st.number_input(
                label = 'min1',
                min_value = 0.00,
                max_value = 1.00,
                value = 0.44
            )

    test2 = st.number_input(
                label = 'min2',
                min_value=0.10,
                max_value=2.10,
                value=0.4
            )
    
    test3 = st.number_input(
                label = 'min3',
                min_value=0.10,
                max_value=2.10,
                value=0.44,
                format = "%0.2f"
            )

Screenshot 2023-11-02 151430

Debug Info:
Python 3.10.13
Streamlit, version 1.28.0
Using Conda Environment

I was unable to replicate your issue.

image


Debug info:
Python 3.11
Streamlit 1.28
Firefox on Windows

Hi, I can confirm some inconsistent behavior.
When I set my browser (Firefox) to a different locale (Like Dutch, Belgium), the number may first show as “4,71” but when I type “4,7” into the box, it changes to “4.70”. Likewise when using the -/+ buttons to change the value, it displays with a “.” instead of a “,”.
So it somehow depends on the number of digits that I enter. I can enter it either as “4.72” or “4,72”, which are both accepted and displayed as I originally entered them.
But “4,7” changes to “4.70”.
Hope this helps clarifying the issue.
It seems silly but if I want to format a whole page using “,” as the decimal separator (which is used in a large part of the world), it would be nice to have it in the number inputs as well.
Thanks!

Also, when I set my browser to English-US, it does NOT accept “4,6” with the “,” as decimal separator. It just ignores my input and uses the previous value.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.