Japan was building the atomic bomb as were we during the war. Thanks to FDR we won the race, and had the means to deliver it. Would Japan have used the bomb on the US if it meant
Japan would win the war?
The Japanese did not have a nuclear program. Our program was created because we thought the Germans were developing the bomb. Turns out they weren't. Since most of the theory was by Jews, Hitler rejected it.
The reality is, we probably didn't need to use it, the Japanese were already looking for a way to surrender.
Let's look at the sequence of events.
We issue our terms for surrender. The Japanese agree to most of them and want to retain the Emperor.
We drop the bomb, and the USSR enters the Pacific War, breaking their non-aggression pact with Japan. As Japan was not really ready for a new front, the Russians pretty quickly start rolling up their forces in Manchuria and Korea.
Now, here's the thing, the last thing Japan wanted was to be partitioned like Germany. And the US didn't want that either. So suddenly we became all cool with Hirohito (a War Criminal as bad as any other) keeping his job.