- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: dcl and floating point values
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 07:36 AM
02-18-2011 07:36 AM
I am writing a com procedure which compute a floating point value at the end. Looks like dcl does not support floating point value.
instead of 0.25 i get 0.
how to achieve this ?
i want com procedure to do the printing of the floating point value. even if i call c program from com procedure to compute floating point
value, how do i return it back to com procedure ?
Scotty
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 07:55 AM
02-18-2011 07:55 AM
SolutionYour option is to maintain your data in strings, or to bias by 10 or 100 or similar hackery.
Here's a general write-up:
http://snow.hoffmanlabs.net/node/487
There are links there to lib$set_symbol and related calls over in Jim Duff's eight-cubed examples library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 08:00 AM
02-18-2011 08:00 AM
Re: dcl and floating point values
You'll have to fake it with strings, and/or change the base unit. That is, do the math in Cents instead of Dollars or Meters instead of Kilometers. You many need to use 2 variables, one for the units, one for the fraction.
Of course then your next problem might be to it to run into the 31 bit 2Gb limitation.
Folks have created tools to deal with this, taking float arguments, return a dcl string symbol. For example:http://www.eight-cubed.com/downloads.html -- MATH
If I can not readily fake it then I try switching the whole script to AWK or PERL.
To help you with the best possible solution we'd need to know more details about what you intend to do.
Maybe and same input + desired output example?
(please use a .TXT for details and/or to maintain formatting if need be.)
Hope this helps some
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 08:04 AM
02-18-2011 08:04 AM
Re: dcl and floating point values
thanks for reply.
i am facing problem accessing the link.
Scotty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 08:09 AM
02-18-2011 08:09 AM
Re: dcl and floating point values
Which link? For Jimm Duff's site I first needed to exploit the google cache, and from there I coudl get to math.zip.
On retry (to test the link in my reply) it worked directly though.
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 08:15 AM
02-18-2011 08:15 AM
Re: dcl and floating point values
thank you for reply
i was not able to access link given by Hoff.
able to access the link you have given. i will try that.
# If I can not readily fake it then I try switching the
# whole script to AWK or PERL.
do you mean AWK/PERL can give more flexibilty than dcl com
procedures ?
any documents on these for me to get started.
Scotty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 08:25 AM
02-18-2011 08:25 AM
Re: dcl and floating point values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 08:35 AM
02-18-2011 08:35 AM
Re: dcl and floating point values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 08:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 08:44 AM
02-18-2011 08:44 AM
Re: dcl and floating point values
procedures ?
If the bulk of the work is string manipulation then yes, absolutely.
Consider the following silly 'one liner':
$ perl -e "for (qx(show dev d/ful)){ $d=$1 if /^Disk\s+(\S+),/; $t=$1 if /al blocks\s+(\d+)/; printf qq(%20s %5.2f%%\n) ,$d,100*$1/$
t if /ee blocks\s+(\d+)/}"
EISNER$DKA0: 36.91%
EISNER$DRA1: 65.56%
EISNER$DRA2: 24.45%
EISNER$DRA3: 57.03%
EISNER$DRA4: 36.03%
EISNER$DRA6: 13.61%
EISNER$DVA0: 20.22%
But it would really help to understand what you want to calculate/process to help suggest what might be best.
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 08:58 AM
02-18-2011 08:58 AM
Re: dcl and floating point values
Same PERL example in a more proper simple program format:
$ type free.pl
$devices = shift; # pick up input argument
$devices = "d" unless $devices; # default to "d" if nothing
for (qx(show dev $devices/ful)) { # execute SHOW DEV and loop over output
$device = $1 if /^Disk\s+(\S+),/;
$total = $1 if /Total blocks\s+(\d+)/;
if (/Free blocks\s+(\d+)/) { # Found last component?
printf qq(%20s %9s %9s %5s\n),
qw(Device Size Free Pct) unless $header_printed++;
printf qq(%20s %9d %9d %5.2f%%\n),
$device, $total, $1, 100*$1/$total;
}
}
$ perl free.pl dr
Device Size Free Pct
EISNER$DRA1: 17768448 11648757 65.56%
EISNER$DRA2: 17768448 4343628 24.45%
EISNER$DRA3: 17768448 10134819 57.04%
EISNER$DRA4: 17768448 6402495 36.03%
EISNER$DRA6: 41891840 5700015 13.61%
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 09:06 AM
02-18-2011 09:06 AM
Re: dcl and floating point values
#Consider the following silly 'one liner':
if i were sitting at the edge of my seat then i would be have
been on the floor by the time i finished reading the silly one liner. haa
#Same PERL example in a more proper simple program format:
thank you a lot. i will read through this.
#But it would really help to understand what you want to
#calculate/process to help suggest what might be best.
we do performance testing a lot, i want comparison results in %.
X is 10.25% faster than Y. but i think i will only get 10 with dcl.
Scotty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 09:21 AM
02-18-2011 09:21 AM
Re: dcl and floating point values
Multiply by 100 before you divide. Use some trickery to insert a decimal point between the last two digits and the rest of the number.
Trickery could be converting to string and inserting the "." into the string. Or doing divide and remainder arithmetic to separate the integer from the fraction.
Or create this tool in a compiled (or assembled) language.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 01:46 PM
02-18-2011 01:46 PM
Re: dcl and floating point values
DCL can do some things well, but other things are slow and cumbersome. Yes, all things are possible if you want to spend unlimited time, but in DCL Floating point is somewhat beyond just slow and cumbersome, it comes in the category of serious masochism and nasty bugs looking for places to cause the most havok.
Forget attempting to implement floating point in DCL for anything other than academic exercise. As Hein has suggested, use Perl. It has floating point already and will be MUCH MUCH faster than anything you can create in DCL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 06:43 PM
02-18-2011 06:43 PM
Re: dcl and floating point values
i will do trickery part in dcl for now as you have suggested.
for long term plans, i would use perl.
does perl come with openvms or do i have to install it seperately ?
any link for download/documentation ?
can dcl and perl talk to each other ?
just like how dcl com procedure can call c program.
can dcl com procedure call perl scripts for doing some work ?
Scotty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2011 10:34 PM
02-18-2011 10:34 PM
Re: dcl and floating point values
sounds reasonable.
>> does perl come with openvms or do i have to install it seperately ?
any link for download/documentation
It does not come bundled but you can find it pre-build as executables bith from the VMS sites and the perl sites.
Easy start:
http://h71000.www7.hp.com/openvms/products/ips/apache/csws_modperl.html
Documentation is all over the web and many books.
I just like to install some distro on my PC and take it from there. Suggestion:
http://h71000.www7.hp.com/openvms/products/ips/apache/csws_modperl.html
>> can dcl and perl talk to each other ?
just like how dcl com procedure can call c program.
Sure, that's what my examples did, and they call called (spawned) commands. Perl program ca n readily get and set dcl symbol to communicate.
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2011 05:33 AM
02-19-2011 05:33 AM
Re: dcl and floating point values
Meant to point to one perl distribution which I have good experiences with: http://www.activestate.com/activeperl/downloads
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2011 07:57 AM
02-24-2011 07:57 AM
Re: dcl and floating point values
Example :-
$ icalc 67.889 + 45.76 /1.45
99.44762069
$ sh sym icalc_out
ICALC_OUT = "99.44762069"
$ icalc
IC> ?
ICALC Version 2.3 of 11-Mar-1999
== Arithmetic Operators == == Trig Functions ==
+ Addition (plus) Note : take radian arguments)
- Subtraction (minus) sin sine
* Multiplication (times) sinh hyperbolic sine
/ Division (divided by) asin arc sine
% Modulus (remainder) cos cosine
^ Power (raised to) cosh hyperbolic cosine
acos arc cosine
== Bitwise Logical Operators == tan tangent
& bitwise AND tanh hyperbolic tangent
| bitwise inclusive OR atan arc tangent
~ unary one's complement atan2 arc tangent of x/y
(2 arguments needed)
== Date Functions == == Math Functions ==
caltojul calendar to julian date exp exponentiation
Usage: caltojul(yyyy, mm, dd) ln natural log
Returns: #days elapsed since October 15, 1582 log base 10 log
jultocal julian to calendar date sqrt square root
Usage: jultocal(julian_date) hypot sqrt(X^2+Y^2)
Returns: date in yyyymmdd format ceil ceiling
Eg: caltojul(1989,12,31) <=> jultocal(148732) floor floor
int,trunc truncation
abs absolute value
degtorad degrees -> radians
== Help Functions == radtodeg radians -> degrees
? Help (print this screen) ran2(0) random in [0,1[
rand(0) random in [0,2^31-1[