I am running into problems using weights in mathematical formulas. What I am trying to do is convert a real number weight into a sayable quantity in the form of pounds and ounces. (see my question below about assigned values–which I finally got to working with the help of Zarf, Jrb and HanonO)

Is there a way I can create a real number variable and have it represent ‘The number part of…(a weight)’, so that I can work with it?? I can’t seem to find anything like that in the manual–unless it’s in the Recipe half…??

If your weights are expressed in a single unit (like 1.2kg), then the easiest way to convert between numbers and weights is just to multiply or divide by 1.0kg as needed. So if W is 1.2kg, then “W divided by 1.0kg” is 1.2. (But you can probably do the arithmetic you need without converting.)

If your weights are compound, as in 5lb 6oz, then you’ll need to name the parts; see section 15.15 of Writing with Inform for the syntax.

Edit: Oh dear, apparently this doesn’t work. It seems that 1.2kg divided by 1.0kg is 1, not 1.2. Surely this has to be a bug?

Thanks zarf. I worked where I was going wrong. I’ll forgive myself, because it’s quite subtle (and because I’m good at forgiving myself).

Mass is a kind of value. 1.0kg specifies a mass.
Weight is a kind of value. 1.2lb specifies a weight.
When play begins:
let W be 1.2kg;
let N be W divided by 1.0kg;
let V be 1.2lb;
let M be V divided by 1.0lb;
say "N=[N], but M=[M]";

Prints “N=1.2, but M=1”.

The value after the point in the specification needs to be 0 for Inform to treat is as a real number. Otherwise it treats it as a sort of compound unit with the value after the point defining the conversion rate. (Makes sense, but could be clearer in the manual.)

Edit: actually, on looking again, I think the manual is downright misleading. Section 15.8 Units: