HP3000-L Archives

September 1999, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
John Zoltak <[log in to unmask]>
Reply To:
John Zoltak <[log in to unmask]>
Date:
Tue, 21 Sep 1999 11:50:39 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (98 lines)
Tad,

Always use COMPUTE var ROUNDED = FUNCTION NUMVAL(string)

Note the ROUNDED keyword. This will solve your problem.

John Zoltak
North American Mfg Co
Cleveland Ohio

> -----Original Message-----
> From: Tad Bochan [mailto:[log in to unmask]]
> Sent: Tuesday, September 21, 1999 11:20 AM
> To: [log in to unmask]
> Subject: [HP3000-L] Cobol NUMVAL Bug/Feature ?
> 
> 
> Hi All,
> 
> I have come across an annoying piece of behaviour from the
>  the otherwise useful COBOL85 function,  NUMVAL.
> 
> As the output of demo program below shows,
> the conversion process seems to truncate the input value,
> depending on the number of implied decimal places in the result.
> 
> Is  this is a 'known' problem  ?
> 
> Regards,
> Tad.
> 
> Passing the string "8236.8 " to NUMVAL gives,
> 
> OUTPUT :-
> 
> RESULT1 =008236.8
> RESULT2 =008236.79
> RESULT3 =008236.799
> RESULT4 =008236.8000
> 
> END OF PROGRAM
> 
> SOURCE :-
> 
> $CONTROL  POST85
>  IDENTIFICATION DIVISION.
>  PROGRAM-ID. NUMVALTEST.
>  ENVIRONMENT DIVISION.
>  DATA DIVISION.
>  WORKING-STORAGE SECTION.
>  01 FILLER.
>   03   ANUMBER     PIC X(12) VALUE "8236.8      ".
>   03   RESULT1     PIC  9(06)v9(1).
>   03   RESULT2     PIC  9(06)v9(2).
>   03   RESULT3     PIC  9(06)v9(3).
>   03   RESULT4     PIC  9(06)v9(4).
> * ---------------------------------------------------------------*
>  PROCEDURE DIVISION.
>  A-000.
>    COMPUTE  RESULT1 = FUNCTION NUMVAL (ANUMBER).
>    DISPLAY "RESULT1 =" RESULT1.
>    COMPUTE  RESULT2 = FUNCTION NUMVAL (ANUMBER).
>    DISPLAY "RESULT2 =" RESULT2.
>    COMPUTE  RESULT3 = FUNCTION NUMVAL (ANUMBER).
>    DISPLAY "RESULT3 =" RESULT3.
>    COMPUTE  RESULT4 = FUNCTION NUMVAL (ANUMBER).
>    DISPLAY "RESULT4 =" RESULT4.
>  A-999.
>       EXIT.
>    END PROGRAM NUMVALTEST.
> 
> PAGE 0001  COBOL II/iX HP31500A.04.19  [85] Copyright 
> Hewlett-Packard CO. 1987
> 
> 
> 
> 
> 
> --------------------------------------------------------------
> ---------------
> This message is confidential; its contents do not constitute a
> commitment by Paribas except where provided for in a written agreement
> between you and Paribas. Any unauthorised disclosure, use or
> dissemination, either whole or partial, is prohibited. If you are not
> the intended recipient of the message, please notify the sender
> immediately.
> 
> Ce message est confidentiel ; son contenu ne représente en 
> aucun cas un
> engagement de la part de Paribas sous réserve de tout accord 
> conclu par
> écrit entre vous et Paribas. Toute publication, utilisation ou
> diffusion, même partielle, doit être autorisée préalablement. Si vous
> n'êtes pas destinataire de ce message, merci d'en avertir 
> immédiatement
> l'expéditeur.
> 

ATOM RSS1 RSS2