Need more decimal places

  • 1
  • Question
  • Updated 5 years ago
Hi. Very green with the API. I would like to acquire the current temp_f and dewpoint_f with two decimal places. When I run my code it returns the values rounded to the nearest whole number. Could anyone guide on how to force the decimal places?

This is my site: http://www.psychroslc.com/data.php

I am using this code:

{'location'}->{'city'};
$temp_f = $parsed_json->{'current_observation'}->{'temp_f'};
$dewpoint_f = $parsed_json->{'current_observation'}->{'dewpoint_f'};
echo "Current temperature in ${location} is: ${temp_f}
Current dew point in ${location} is: ${dewpoint_f}\n";
?>

Thanks!

Steve
Photo of AVSteve42

AVSteve42

  • 2 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of ocpaul20

ocpaul20

  • 2 Posts
  • 0 Reply Likes
Think like a scientist - they always ask what is the margin of error for data. If you ask yourself the same question the answer is probably, for temperature, to the nearest whole degree so tenths would be pretty useless to the common person. Why do you need temperatures or data to be this accurate?
Photo of Brendan Hayes

Brendan Hayes, Official Rep

  • 962 Posts
  • 122 Reply Likes
It depends on where the weather is coming from. The weather from an official will have no decimals, and the temps from a PWS will have 1 decimal place. This is just how we get the data, so there's no way to change that.
Photo of AVSteve42

AVSteve42

  • 2 Posts
  • 0 Reply Likes
I am an engineer in the HVAC field. We work with the psychrometric chart heavily. I have noticed since I posted this question that the temp value returned will occasionally include a single decimal point. It looks like I just take what I get and that will sometimes include a decimal.

Thanks for your responses.