Obviously this is speculative but how much truth can be said to be behind this statement?
The error in the argument is the idea that if the money wasn't used for X it would have been used for Y. Nobody in the CCP said, "let's spend our money on nuclear weapons and let people starve instead." The famine was more complicated than that, the bomb was more complicated than that. It is sort of like arguing that every death in any country due to poverty or starvation or preventable disease is directly offset by any other form of national spending (e.g., every meal that a politician eats which is paid for by taxpayer money is directly taken out of the mouth of someone hungry).
That being said, there are sometimes ways in which you can make direct connections. The Nazi V-2 program, for example, had more people die in the hellish conditions for slave (Holocaust) labor building the missiles than who actually died because the missiles killed them in war — that's a direct connection (and an important one to make, historically, because it illustrates the unsustainability of this particular project).
And there is, of course, a general, indirect argument to be made about spending on arms. As Eisenhower famously put it in 1953, "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed." But that logic applies to all nations, all spending. If you apply that argument to Hiroshima and Nagasaki as well, the US expenditure "killed" far more than who died at Hiroshima and Nagasaki, since there were other things that money could have been spent on. There are, to be sure, serious opportunity costs for this sort of spending, as one of my favorite political illustrations about nuclear weapons emphasizes very cleverly (I have this poster on my office door, because I think it is unusually probing and well-executed).
But the defenders of military programs, especially nuclear programs, could always cook up their own counter-hypotheticals. How many Chinese would have died, they would argue, if they had not built a nuclear arsenal? US war planners in the late 1950s calculated that they would kill hundreds of millions of Chinese from blast and fallout alone (to say nothing of the subsequent starvation and strife that would come to all survivors), and the Chinese bomb program was a direct response to American nuclear threats against non-nuclear China. This is exactly the kind of justification used to defend military and nuclear spending in all nations.
All of which is to say, I am entirely sympathetic with seeing the "costs" of military and nuclear programs as being far larger than whomever happens to be killed by the weapons directly. Nations which spend billions or trillions (in the US and Soviet cases, over the length of the Cold War and beyond) of dollars on these weapons are doing so at the expense of their populations in very real ways. But this kind of "direct" claim (this program cost X lives, because they didn't buy food) strikes me as an error of historical causality. It is more complicated than that. And I suspect authors who make this sort of claim about other countries rarely are willing to have the logic applied more universally (if they are, then I'm more sympathetic — but if only gets applied selectively to "bad" countries, well, I'm not).
Separately, on the numbers — I think 38M is an acceptable number (within the range of estimates) for famine deaths, and $4.1B for the Chinese bomb program sounds about right (it is the same amount listed in Lewis and Xue, China Builds the Bomb, on page 108, which is a reputable source). With both numbers, you could "work them up" if you wanted to, because of extended costs — for example, bomb program costs usually focus on warhead development, not everything else associated with making a nuclear weapon system, and in any event converting currencies historically for large projects like this involves a lot of guesstimation. But anyway, the numbers check out fine, it's the relationship between them that is tricky.
I will preface this by saying I'm not specifically a China expert (nor a nuclear expert).
Anyway, first I think it's worth placing Chang and Halliday's book in some perspective. It came out in 2005, and caused a bit of a controversy at the time, to the point that there is in fact an entire rebuttal that was published by academic historians in response. The main arguments historians make against Chang and Halliday's book are as follows. It claims to describe many new and shocking details of Mao's life and political career, while in fact much of what they write about has already been written on (including his quite terrible personal life). The book furthermore selectively uses sources to paint Mao in the worse possible personal light (an example given is how a Chinese general is treated as a reliable source in the book, but his account of Mao's shock at the news of his son's death in the Korean War is ignored in order to paint Mao as someone personally uncaring over even the death of family members). And finally, a big part of painting this portrait of Mao in the worst possible light is so make Mao appear solely as a power-hungry figure with no real concern for the ideology he espoused. Not only does much of this rely on selective use of sources, but it also contradicts earlier works of Chang and Halliday. This kind of issue sounds very familiar to me in terms of Soviet histories, especially biographies of Stalin (and less so but also Lenin).
Anyway, Chang and Halliday's claims around the Chinese nuclear program are a central part of this thesis, and one that Benton, Chun et al. take issue with. A major part of the issue being that it ignores the geopolitical situation the People's Republic of China was in in the 1950s. Whatever one may think of Mao or the CCP, they clearly saw external threats, and often with justification. The United States government (with concern from its allies) had publicly discussed use of nuclear weapons against the PRC in 1953, just at the end of the Korean War, and again during the Taiwan Strait Crisis of 1954-55 and 1958. China having its own nuclear weapons program and nuclear deterrent was therefore not just a megalomaniacal fancy of Mao (although apparently Chang and Halliday actually use these threats to argue that, claiming it was "music to Mao's ears").
An issue with Chang and Halliday's argument at least as presented here is that it ignores the fact that the Chinese nuclear program was not something the PRC conducted all by itself, from scratch. The PRC was a recipient of massive Soviet development aid (in terms of materiel and advisors) during the 1950s, up until the Sino-Soviet Split of 1960, and this very much included its nuclear program, with the USSR sending a prototype bomb and technical components to the PRC, as well as advisers to help the Chinese build enrichment facilities). So frankly I'm not sure exactly how Chang and Halliday are breaking down this cost - is it the entire cost of the program? Or just what the PRC spent?
A next point is a much broader one. The Great Leap Forward is clearly a manmade famine that caused excess deaths upwards of some 30 million people between 1957 and 1961, and much of the responsibility within the PRC for this can be laid at the feet of Mao for pushing for the agricultural and industrial policies that he did. With that said, it's kind of a false choice being presented here - that if the PRC hadn't spent money on its nuclear program, it could have spent money on saving all of the people who died in relation to the Great Leap Forward (even though this is a diffuse concept as hinted at by the "excess deaths" measure - most people don't die directly from starvation in famines as much as through secondary vectors caused by weakened immune systems and malnutrition). Anyway I have problems with this argument. One is that these kinds of investments aren't interhangeable - I'm not sure how you could turn uranium mining, enrichment facilities, and nuclear physicists into a means of producing more food, nor could the Soviet aid (technical or human) be transferrable to supplying food either. It also misleads in why the Great Leap Forward famine occurred. The famine was much more the result of a misallocation of resources and human labor in agricultural and industrial projects rather than a misallocation of resources directly to the nuclear program. Pushes for increased collectivization and the banning of private farming plots, local cadre pushes for increased output and very bad management means for those at the top of the leadership understanding what was actually happening at the village level, poor irrigation projects and hare-brained schemes like the backyard steel furnace program had far more to do with the famine than the nuclear program. The great tragedy of the famine is that it in many ways repeated Stalin's mistakes (and often by intentionally using Stalin as a model) that lead to the Soviet famine of the early 1930s.
Finally, I think the comparison to Hiroshima and Nagasaki is disingenuous. Whatever one may think of the use of those two bombs, it was an actual conscious event: two bombs were dropped on cities. It's not really comparable to use a demographic excess death count from a famine to that, and to furthermore lay that famine's death toll entirely at the feet of a nuclear program. If this were an honest argument, then at the very least the authors should be asking how many excess deaths could be laid at the feet of the Manhattan Project diverting massive economic and technical resources (again, I don't think you can even make these sorts of claims realistically, but I note that if someone is going to make the argument for the PRC, they should at least apply that even-handedly to the other country they're comparing it to). It just comes across as disingenuous and trying to win an argument by death count.
And here I am spending my Monday defending Mao. I was...not planning on this, and again I need to emphasize that there are a lot of brutal acts and callousness in his leadership that caused the deaths and suffering of millions (and again, that's not even getting into his pretty horrible treatment of people around him on a personal level). But regardless of that, people can use bad historic practice and bad arguments when writing about bad people, and that looks like what is happening here.