battery voltage

Hi,
I havve a question related with reading battery voltage,
I know it is so simple but my reading outputs are not logic,
I use 3.7v battery for suppyling system (and external step up),
with a simple voltage divider (equal resistance values, after first one I connect to A0 directly. and to second one and ground)

float voltage = sensorValue * (5.0 / 1023.0);

May I change this 5.0 to 3.7 ?
While I use another battery which is 6.0, the parameter in this line is 5.0 and my results are true,
So I am confused,

Thank you

float voltage = sensorValue * (5.0 / 1023.0);

Replace 5.0 (Vcc) with the analog reference voltage. If the analog reference is default (not specified INTERNAL or EXTERNAL), it is Vcc (whatever voltage that Vcc is). If you are using an internal or external reference, then aref is that voltage.

First of all, is your arduino running 5V or 3.3V logic? If you are running 5V logic (with a DC-DC converter to get 5V out of 3.7V), then you can connect adc directly to the battery. If you're running at a lower voltage, say 3.3V, use the voltage splitter and replace the 5.0V with 3.3V. The 5.0V is the voltage that arduino runs at, not the battery's voltage.

The 5 in the line 5.0/1023.0 refers to the voltage "ref" (reference) which is equal to the running voltage of the arduino, and is usually about 5 when powered through the usb or the built-in regulator of some arduino boards.
If in doubt, measure yours at REF
Hopefully your 6V battery goes through a built-in linear regulator to decrease to 5V presented to the arduino chips.

I think at sensorValue = 1023 you need to print out your max. cell voltage, which may be 4.2V since 3.7V nominal is typical for Lipo or NMC cells.