Jump to content

How Do I Shorten The Answer To A Multiplication Operator?


joshspaulding

Recommended Posts

Another basic one for you. I just created a little script that asks the user for the current weight of their baby and when submitted it tells them how much breastmilk their baby needs per hour and per day.

 

But the per hour numbers look like this (for example) 0.916666666667

 

How can I make it look like this: 0.9 ?

 

Thanks!!

Edited by joshspaulding
Link to comment
Share on other sites

Thanks guys!! Sorry for the newbness lol but how would I implement that in this code?

 

$minoz = $_POST['weight'];
$outcomeMin = $minoz * 2;
$outcomeMax = $minoz * 2.5;
$outcomeHourlymin = $outcomeMin / 24;
$outcomeHourlymax = $outcomeMax / 24;


echo "Your baby needs from $outcomeMin oz. to $outcomeMax oz. of breastmilk per day or $outcomeHourlymin oz. to $outcomeHourlymax oz. per hour."

Link to comment
Share on other sites

Floating point numbers are inherently inaccurate. As such it's often best to either multiply the numbers so that you're working with integers, or use the bcmath library. At least if you require accuracy (such as in accounting, etc.)

 

However, for your case it should be enough to surround the outcome calculations in a round () call. The PHP manual contains more information on how to use round (), should you be confused as to how to use it.

 

Edit:

And... You solved it while I was typing. Oh, well. Good to hear that, at least. :)

Edited by Christian F.
Link to comment
Share on other sites

Another basic one for you. I just created a little script that asks the user for the current weight of their baby and when submitted it tells them how much breastmilk their baby needs per hour and per day.

 

The amount of breastmilk a baby needs to consume has literally NOTHING to do with their weight. It has everything to do with their age and other undeterminable variables. From birth to 6 months all babies regardless of weight need 24-30 oz of breastmilk per day. The general rule is 1-1.5 oz per hour. It is not dependent on their weight. 

 

After 6 months (when solids are introduced) babies will slowly drop their breastmilk consumption in favor of food, but it can take until 12 months or longer for babies to be eating a lot of food. Regardless of what age they are, the amount of milk they need to consume stays relatively the same. The milk changes in composition as baby grows. A mom of a 1 year old actually produces different milk than when the baby was 1 week old. Baby will probably drink about the same on average.

 

Premature babies will need less breastmilk as well, dependent on just how premature they were. 

 

In addition, the primary reason someone would need this information is if they are pumping and leaving the baby with a caregiver. Once the baby is a few months old they can reliably reverse cycle and choose to sleep more during the day and nurse more at night. This means they'd be consuming less milk during the day and more at night. Pumping is usually fairly ineffective, so it's actually easier on the moms if the baby does this. If they read something that says their baby should be getting X oz per hour, and the mom can't pump that much, and/or the baby refuses to take that much milk in favor of waiting for mom to return, it undermines mom's confidence in her ability to feed her baby. Then the baby hits a growth spurt and needs to nurse more, and mom thinks either she can't make enough milk, or the baby shouldn't have so much milk, or something is wrong, when it's really the natural pattern of a baby growing.

 

The "tool" you are attempting to create is at best, inaccurate, and at worst, hurting breastfeeding moms. 

Edited by Jessica
Link to comment
Share on other sites

The amount of breastmilk a baby needs to consume has literally NOTHING to do with their weight. It has everything to do with their age and other undeterminable variables. From birth to 6 months all babies regardless of weight need 24-30 oz of breastmilk per day. The general rule is 1-1.5 oz per hour. It is not dependent on their weight.

 

After 6 months (when solids are introduced) babies will slowly drop their breastmilk consumption in favor of food, but it can take until 12 months or longer for babies to be eating a lot of food. Regardless of what age they are, the amount of milk they need to consume stays relatively the same. The milk changes in composition as baby grows. A mom of a 1 year old actually produces different milk than when the baby was 1 week old. Baby will probably drink about the same on average.

 

Premature babies will need less breastmilk as well, dependent on just how premature they were.

 

In addition, the primary reason someone would need this information is if they are pumping and leaving the baby with a caregiver. Once the baby is a few months old they can reliably reverse cycle and choose to sleep more during the day and nurse more at night. This means they'd be consuming less milk during the day and more at night. Pumping is usually fairly ineffective, so it's actually easier on the moms if the baby does this. If they read something that says their baby should be getting X oz per hour, and the mom can't pump that much, and/or the baby refuses to take that much milk in favor of waiting for mom to return, it undermines mom's confidence in her ability to feed her baby. Then the baby hits a growth spurt and needs to nurse more, and mom thinks either she can't make enough milk, or the baby shouldn't have so much milk, or something is wrong, when it's really the natural pattern of a baby growing.

 

The "tool" you are attempting to create is at best, inaccurate, and at worst, hurting breastfeeding moms.

 

lol This is not a tool that I'm releasing to the public and I'm not looking for medical advice, only PHP advice ;)

Link to comment
Share on other sites

LOL yeah it's so funny isn't it?

 

You aren't looking for medical advice, you're just creating a tool to dispense medical advice based on invalid assumptions. "I just created a little script that asks the user for the current weight of their baby". 

 

To ignore the harmful implications of this would be as if I ignored you saying you were creating a tool that asked users for the color of their baby's hair and told them how much food to feed them. It's irresponsible. 

 

If you don't want criticism of your ideas, don't post them on the internet. If you want to actually do something useful, there is plenty you can do besides this "tool". You have an opportunity to learn more about a subject, and instead you respond with "LOL" and dismiss it. Shame on you.

Link to comment
Share on other sites

P.S. Although this is 100% off-topic and probably shouldn't even be discussed here and since you seem to be so concerned with what I'm doing: The metrics come from our Pediatrician (what is your medical degree by the way?) who advised us that our son (not yours, or anyone else's) should be getting about 2x's to 2.5x's his body weight in pounds for the first 6 months of his life.

 

Thank you for being so concerned though and I wish you the best of luck with your medical career. :)

Link to comment
Share on other sites

Please do some research, because your pediatrician is 100% wrong. It's very easy to find accurate information on this topic. That doctor clearly doesn't understand the difference between breastmilk and formula, something you don't need a medical career to know about, and something which doctors are notorious for being ill-informed on.

 

The only semi-accurate way to know how much breastmilk a baby gets when nursing is by weighing it before and after a feed. Pumping is not a reliable indicator of how much milk a woman produces.

 

The amount of breastmilk a baby needs is not related to their body weight. It's very easy to find that out, you can look online or in print, and talk to people who actually know what they're talking about like La Leche League, or an IBCLC. But a Ped is usually the least informed person on breastfeeding. There are easy signs to see if a doctor actually knows about breastfeeding, and telling someone something like the amount of milk is related to the baby's weight is a BIG red flag.

 

If you care about the baby and mom having a successful breastfeeding relationship, you will do some actual research on the topic, rather than taking his word or my word for it. The reason I am concerned is you said this was a script for a "user". Most people don't create web based scripts for a simple calculation they could do in excel for themselves. They create them to publish them. If you're not going to publish it then fine, but I hope for your own families sake that you do look into the inaccurate comments your doctor is making. 

Link to comment
Share on other sites

Please do some research, because your pediatrician is 100% wrong. It's very easy to find accurate information on this topic. That doctor clearly doesn't understand the difference between breastmilk and formula, something you don't need a medical career to know about, and something which doctors are notorious for being ill-informed on.

 

The only semi-accurate way to know how much breastmilk a baby gets when nursing is by weighing it before and after a feed. Pumping is not a reliable indicator of how much milk a woman produces.

 

The amount of breastmilk a baby needs is not related to their body weight. It's very easy to find that out, you can look online or in print, and talk to people who actually know what they're talking about like La Leche League, or an IBCLC. But a Ped is usually the least informed person on breastfeeding. There are easy signs to see if a doctor actually knows about breastfeeding, and telling someone something like the amount of milk is related to the baby's weight is a BIG red flag.

 

If you care about the baby and mom having a successful breastfeeding relationship, you will do some actual research on the topic, rather than taking his word or my word for it. The reason I am concerned is you said this was a script for a "user". Most people don't create web based scripts for a simple calculation they could do in excel for themselves. They create them to publish them. If you're not going to publish it then fine, but I hope for your own families sake that you do look into the inaccurate comments your doctor is making.

 

No offense, but I think I'll get my health advice from doctors and my php advice from here ;) Have a good one.

Link to comment
Share on other sites

Jessica - I actually agree with doing your own research. Doctors also recommend vaccines and crazy amounts of antibiotics when they aren't needed, which often times does more harm than good. But the fact is, we are in a PHP forum :) Not a health discussion forum. The script I referenced above, as I said, is for our own use and really it's not even for our own use... it's just something I threw together for a little practice.

 

This is why it's usually not a good idea to assume things ;) Lets stick to PHP, since we're in a PHP forum. Then we won't have to waste our time with pointless arguments.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.