| Author | 
         | 
         
      
        
         
         GadgetGuy Super User 
          
  
  Joined: June 01 2008 Location: United States
 Online Status: Offline Posts: 942
          | 
        
         
          
           | Posted: February 09 2009 at 22:05 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
When I use a function like 
 
 
 I would expect it to always produce a single digit to the right of the decimal point. 
 
 Thus 32.57 would be 32.6 and 32.0 would be 32.0, but I'm finding that a whole number like 32.0 seems to produce a result of "32" without any decimals.
 
 On my home web page where I am trying to present various temperatures, I would like them to all be consistent and not add/drop a digit to the right of the decimal.
 
 what I am getting is . . .
  
 
 But what I would like is for the 38 degree temp to be presented as 38.0, which the round does not seem to be doing.
 
 The value appears in a Global var and is stored there as 38 even though I created it from data with the round() function.
 
 Is there a way to always get one decimal digit?    
  __________________ Ken B - Live every day like it's your last.  Eventually, you'll get it right!
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         dhoward Admin Group 
          
  
  Joined: June 29 2001 Location: United States
 Online Status: Offline Posts: 4447
          | 
        
         
          
           | Posted: February 09 2009 at 22:15 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Of course, it's PowerHome  .
 
 Try:
 
 
 This will give you what you want including the actual rounding.
 
 HTH,
 
 Dave.
 
         | 
       
       
        | Back to Top | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         GadgetGuy Super User 
          
  
  Joined: June 01 2008 Location: United States
 Online Status: Offline Posts: 942
          | 
        
         
          
           | Posted: February 10 2009 at 10:51 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Dave thanks.
 
 Actually please note, I wanted to do something like that but the Documentation, while continually talking about "Format CHaracters" never defines them anywhere I could discover.
 
 I tried a number of things like "n.n" and "#.#" but never thought of the correct one.
 
 This would be a good thing to make sure it gets documented somewhere.
  __________________ Ken B - Live every day like it's your last.  Eventually, you'll get it right!
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         GadgetGuy Super User 
          
  
  Joined: June 01 2008 Location: United States
 Online Status: Offline Posts: 942
          | 
        
         
          
           | Posted: February 10 2009 at 11:32 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
A little Post Script.
 
 While the above approach did gave me a Global value with single decimal precision, as I wanted, I was still getting an integer number on my web page whenever the temperature data readings were whole numbers (such as 2.0 for the Freezer)
 
  
 
 To fix this last step I had to edit my HTML code for the web page and make the PH ASP calls. . .
 
Code: 
   
    
    
      
       | <%string(ph_getglobal_n("TEMP-FREEZER"),"#.0")%> | 
       
       | 
    
    | 
 
 
 
 That is, I had to add the string function here too, as the simplier getGlobal function returned an integer value.    
  __________________ Ken B - Live every day like it's your last.  Eventually, you'll get it right!
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         dhoward Admin Group 
          
  
  Joined: June 29 2001 Location: United States
 Online Status: Offline Posts: 4447
          | 
        
         
          
           | Posted: February 10 2009 at 13:09 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
If the global already has the proper format with the trailing decimal, then you should also be able to just use:
 
 <%ph_getglobal_s("TEMP-FREEZER")%>
 
  
 
         | 
       
       
        | Back to Top | 
         
          
          
         | 
       
       
       
        |   | 
      
        
         
         GadgetGuy Super User 
          
  
  Joined: June 01 2008 Location: United States
 Online Status: Offline Posts: 942
          | 
        
         
          
           | Posted: February 10 2009 at 13:43 | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Dave - Ah So!
 
 I just wrote a long Reply here telling you that was what I had done, and that it didn't work when I noticed I had been using getglobal_n not getglobal_s as you suggest.
 
 So mea culpa.  I deleted my long story and replace it with this humble "thanks."  Your insight is quite valid.   
  Edited by GadgetGuy - February 10 2009 at 13:44
  __________________ Ken B - Live every day like it's your last.  Eventually, you'll get it right!
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   |