Post Reply 
Problem with convert
10-28-2015, 01:37 AM (This post was last modified: 10-28-2015 01:38 AM by Han.)
Post: #8
RE: Problem with convert
(10-28-2015 12:40 AM)epp Wrote:  CONVERT(1_h,1_s): yielded 3600_s
CONVERT(1_h,1_mn): error
CONVERT(1_h,1_'min'): entered from command-line, note the quotes that were added by the calculator
CNV(1_h): program calls CONVERT(1_h,1_min), OK
CNV(1_h): program calls CONVERT(1_h,1_mn), error

In a nutshell, from the command-line I can't get minutes to work. From a program min works but mn does not.

CNV() is an HPPPL program and therefore a non-CAS program. HPPPL programs assume that all commands are "non-CAS" so that even when one types: convert(1_h, 1_min) the command is interpreted as CONVERT(1_h, 1_min). And since this is considered to be evaluated in the Home view (i.e. non-CAS side), all is well. Even calling CNV() from the CAS view using "min" for minutes would be fine because the command line parser sends all the inputs to CNV() and everything is treated as if it were run from the Home view (since CNV() is a non-CAS program).

The CAS side runs on XCAS/GIAC which also has support for units. XCAS comes with a command called convert(). It also has a min() command. Thus, to avoid conflict, I believe the minutes unit has been renamed to "mn" -- within XCAS. So, in the CAS view, if one types: convert(1_h, 1_mn) the calculator will return: 60._mn. However if one types CONVERT(1_h, 1_mn) in the CAS view, then the parser uses the Home version of the command, which does _NOT_ recognize "mn" as a proper unit. As far as CONVERT() is concerned, there is no such unit as "mn" and the minute unit is "min". This is what you are seeing insofar as discrepancies are concerned.

In general, if you look in the catalogue of commands, commands that show up in all caps tend to be non-CAS commands. They will usually be copied to the command line in upper-case. Similarly, the lower-case commands are usually CAS commands (i.e. commands that are meant to be run from the CAS view). However, some commands have two versions. Generally speaking, if you are on the CAS side, and you select and all-caps command _and_ it is copied to the command line in lower case, then you have an instance of a command that has both CAS and non-CAS versions (example: MAKEMAT and makemat). I say generally speaking because CONVERT unfortunately does not behave as just described (only the upper-case command is ever copied from the catalogue to the command line).

Lastly, a shorthand for unit conversion is to use the "STO>" arrow. For example: 1_h > _s (note that the second unit does not have a scalar value -- it's just the unit itself)

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Problem with convert - Natoe - 10-27-2015, 06:04 PM
RE: Problem with convert - Natoe - 10-27-2015, 06:17 PM
RE: Problem with convert - epp - 10-27-2015, 09:42 PM
RE: Problem with convert - Han - 10-27-2015, 09:48 PM
RE: Problem with convert - epp - 10-27-2015, 10:23 PM
RE: Problem with convert - Han - 10-27-2015, 11:28 PM
RE: Problem with convert - epp - 10-28-2015, 12:40 AM
RE: Problem with convert - Han - 10-28-2015 01:37 AM
RE: Problem with convert - epp - 10-28-2015, 01:44 AM



User(s) browsing this thread: 1 Guest(s)