b3ta.com talk
You are not logged in. Login or Signup
Home » Talk » Message 6234090 (Thread)

lamb chili (with mozerella) and an assortment of steamed veg.
tj for the maths boffs:

If I have a number of variable length, e.g. 439, how do I get the 'middle' number (3 in that example)?
(, Wed 17 Jun 2009, 17:47, archived)
Count in from either end and see where your fingers meet.

(, Wed 17 Jun 2009, 17:48, archived)
Are you talking about coding?

(, Wed 17 Jun 2009, 17:50, archived)
Because you could do something with substrings
or, I think, mod might be able to do it.
But don't quote me on that.
(, Wed 17 Jun 2009, 17:51, archived)
Not possible using a math approach.
Plus if the string is an even number of numbers - problem.
(, Wed 17 Jun 2009, 17:55, archived)
no, arithmetic.
if it were coding, it'd be peasy..

echo $num[floor(strlen($num)/2)];

(, Wed 17 Jun 2009, 18:02, archived)
All decimal numbers can be written "long-hand" as
c0 × 100 + c1 × 101 + c2 × 102 + ... + cn × 10n (more typically written as cn...c2c1c0; e.g. 439 is 4 × 102 + 3 × 101 + 9 × 100.)

you should first find n, divide it by two, and you've got the power of 10 the middle digit multiplies. From there, it gets a little complicated.
(, Wed 17 Jun 2009, 18:16, archived)
write the number on a sticker
stick the sticker to a dog
push the numbered sticker stuck dog into a usb hole
(, Wed 17 Jun 2009, 17:51, archived)