Yet another snag...real numbers and 'total (value) of..."

In my review game, I shifted the weights of my items from (whole) numbers to real numbers, now they have weights like 2.0 pounds, 1.0 ounce, 5.0 pounds, the player has a weight of 217.0 pounds, the NPC is 175.0 pounds, etc.

Now it seems that this throws the ‘total (value) of…’ function out of whack. To find the source of the problem, I ripped out all of my rules dealing with weights, leaving only a few things, and here is my entire code about weights–

[code]When play begins:[9.1]
say “You wake up in your office. In front of you is your usually blank sheet of paper–you did away with the typewriter a long time ago, given that it was so thoroughly under-used. Your character stands here, waiting for you to tell him what to do…[paragraph break]”;
say “You agonize over what you should write…”;
now the command prompt is " >";[8.2]
repeat with item running through things:
if item is a part of something:
now item weighs 0.0 ounces.

A weight is a kind of value.
The verb to weigh means the weight property.
1.0 ounce (singular) specifies a weight. [15.8]
2.0 ounces (plural) specifies a weight.
1.0 pound (singular) specifies a weight scaled up by 16.
2.0 pounds (plural) specifies a weight scaled up by 16.

Definition: A thing is light if its weight is 80.0 ounces or less.
Definition: A thing is heavy if its weight is 81.0 ounces or more.

A digital scale is here. It is scenery. The description is “It’s attached to the bench by unseen wires. The readout says, in red digits-- [totalweight].”
To say totalweight:
say “[the total weight of things enclosed by the long bench]”.[This is where the problem occurs]

Everything has a weight. The weight of the player is 217.0 pounds. The weight of John Diddling is 175.0 pounds.
A thing usually weighs 1.0 ounce. The nickel-plated revolver weighs 2.0 pounds. The radio weighs 1.0 pound. A popcan weighs 1.0 pound. The trench coat weighs 10.0 pounds. The fedora weighs 1.0 pound. The duffel bag weighs 2.0 pounds. A cutknife weighs 2.0 ounces. The large wedge of cheese weighs 5.0 pounds. The iron key weighs 1.0 ounce. A nail weighs 1.0 ounce.
[/code]

John Diddling is my NPC. ‘Popcan’, ‘cutknife’ and ‘nail’ are kinds. The numbers in brackets are cross-references to the manual.
The problem is that when I put certain combinations of things on the bench, the result is extremely small–reported in scientific notation, using negative powers of 10! When I had the other rules in, it was reporting my NPC’s weight as -17800 ounces! Is it because the ‘total…’ function is not designed to work with real numbers?

Thanks

Totally disregard this–it finally hit me what Zarf said–I divided by 1 ounce—here is my whole code about the total weight–

A digital scale is here. It is scenery. The description is "It's attached to the bench by unseen wires. The readout says, in red digits-- [totalweight]." Allweight is a weight that varies. Ounceweight is a real number that varies. Firstweigh is a real number that varies. Poundweight is a real number that varies. Poundfloor is a real number that varies. Poundweigh is a number that varies. Poundfract is a real number that varies. Ounceweigh is a number that varies. To say totalweight: now allweight is the total weight of everything enclosed by the long bench; now firstweigh is allweight divided by 1 ounce; now poundweight is firstweigh divided by 16; now poundfloor is floor of poundweight; now poundweigh is poundfloor to the nearest whole number; now poundfract is poundweight minus poundfloor; now ounceweight is poundfract * 16; now ounceweigh is ounceweight to the nearest whole number; if poundweigh >= 1: say "[poundweigh] pound[s][if ounceweigh > 0][ounceweigh] ounce[s]"; otherwise: say "[ounceweigh] ounce[s]"

It works neatly and cleanly. Thanks Zarf.

Yes, this seems to be totally broken. A smaller example:

A thing has a real number called the X. The X of the player is 1.0. The X of the banana is 1.0.
When play begins: say "[the total X of things].";

Prints “1.70141 × 10^38kg.”

Edit: this is a known issue, 0001935 in the Bug Tracker.

Oh, also I converted all my assigned weights into (whole) number weights.

If you want to leave them in the original units (as real numbers), you could write your own adding routine. Something like this:

To decide what weight is the overall weight of (S - a description of things):
	let W be 0.0 ounces;
	repeat with the next item running through S:
		now W is W plus the weight of the next item;
	decide on W.

Now you can write things like “[overall weight of things on the bench]”.

Thanks JRB, and thanks for your patience.

You haven’t tested my patience yet. I enjoy tinkering with Inform.