HP Forums
(Solved) PRINT: Unexpected HMS formatting/Unexpected DMS formatting - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: (Solved) PRINT: Unexpected HMS formatting/Unexpected DMS formatting (/thread-6987.html)



(Solved) PRINT: Unexpected HMS formatting/Unexpected DMS formatting - StephenG1CMZ - 10-07-2016 05:45 PM

I assumed that if I asked for
PRINT(LATITUDE+" " +HMS(LATITUDE))
I would see the latitude in both decimal and HMS/DMS format.
This does not happen.
Instead, the first variable is printed as it was provided (either HMS or decimal).

Is this intended?
Code:

A_VIN(LAT1,LON1,LAT2,LON2)
 BEGIN
  LOCAL TM,RESULT,DISTS;
  PRINT("From LAT "+LAT1+" "+→HMS(LAT1));  
 END;

EXPORT HMSPRINT()
BEGIN
  PRINT(); 
  A_VIN(50°03′58.76″,−005°42′53.10″,58°38′38.48″,−003°04′12.34″);//Expected 50.decimal not 50 03 output twice
 
  A_VIN(50.5,45.5,35.,34.4);

END;

//Outputs:
//From LAT 50°03′58.76″ 50°03′58.76″ //Unexpected 
//From LAT 50.5 50°30′00″ //Expected


What is the recommended way to see both formats, without caring how it was entered?
(Android version)


RE: PRINT: Unexpected HMS formatting/Unexpected DMS formatting - toml_12953 - 10-07-2016 07:30 PM

(10-07-2016 05:45 PM)StephenG1CMZ Wrote:  I assumed that if I asked for
PRINT(LATITUDE+" " +HMS(LATITUDE))
I would see the latitude in both decimal and HMS/DMS format.
This does not happen.
Instead, the first variable is printed as it was provided (either HMS or decimal).

Is this intended?
Code:

A_VIN(LAT1,LON1,LAT2,LON2)
 BEGIN
  LOCAL TM,RESULT,DISTS;
  PRINT("From LAT "+LAT1+" "+→HMS(LAT1));  
 END;

EXPORT HMSPRINT()
BEGIN
  PRINT(); 
  A_VIN(50°03′58.76″,−005°42′53.10″,58°38′38.48″,−003°04′12.34″);//Expected 50.decimal not 50 03 output twice
 
  A_VIN(50.5,45.5,35.,34.4);

END;

//Outputs:
//From LAT 50°03′58.76″ 50°03′58.76″ //Unexpected 
//From LAT 50.5 50°30′00″ //Expected


What is the recommended way to see both formats, without caring how it was entered?
(Android version)

The Prime keeps track of the format of the variable. If you entered it in decimal degrees, then it will stay that way. Likewise if you enter it in HMS format, then it will print that way. To always print in decimal degrees no matter what was entered, you could do this:

Code:
PRINT(HMS->(->HMS(LATITUDE))+" "+LATITUDE)

Tom L


RE: PRINT: Unexpected HMS formatting/Unexpected DMS formatting - Tim Wessman - 10-07-2016 08:19 PM

It is actually a flag embedded in the number object itself.

Whichever format was entered, use the ->HMS or HMS-> to set that flag. There is not any calculation that happens - it is purely setting the flag.

Here's the code for those commands if you are curious:

Code:
static THPObj *CallHMS2(THPVarFuncDef const *f, THPObj const **Params, Int NbParams)
{
  HP_Real r; if (!Params[0]->GetReal(&r)) return &HPERBadArguementType;
  r.Flags&= ~FDMSDisplay;
  return THPObj::NewReal(&r);
}
static THPObj *Call2HMS(THPVarFuncDef const *f, THPObj const **Params, Int NbParams)
{
  HP_Real r; if (!Params[0]->GetReal(&r)) return &HPERBadArguementType;
  r.Flags|= FDMSDisplay;
  return THPObj::NewReal(&r);
}



RE: PRINT: Unexpected HMS formatting/Unexpected DMS formatting - eried - 10-07-2016 10:24 PM

Maybe is not the correct Arguement lol Big Grin