How to get X bins of a TH2D

Hello,
I am trying to get X bins of a TH2D, attached is a testing code
I expect I can get the same number by two ways. But they are not same. I did wrong things here?

Thanks,
Zhiyi.
testGetBins.C (276 Bytes)

you should call TAxis::GetBinCenter.
GetXbins is to get the low edge position of bins in case of a variable bin width histogram.

Rene