putz@boulder.Colorado.EDU (Eric Putz) (01/10/90)
I am having a problem getting writeln to output a number with a decimal value of 0, not in the 'e' format, and am not sure if this is a compiler bug, or a feature of pascal. I have tried the following lines with the following results: writeln(1.0:1:1) gives me 1.0 writeln(1.0:1:0) gives me 1.0e+00. What I was hoping for was 1 when writeln was given a decimal value of 0. All other decimal values I have tried (> 0) have worked correctly. The compiler I am using is MIPS Pascal 2.0 (from RISC/os4.00 & cmplrs2.0) on an M2000. Any thoughts? Thanks in advance. +--------- |Eric Putz (303)492-1474 |MCD Biology, Campus Box 347, University of Colorado, Boulder CO 80309 |putz@Boulder.Colorado.EDU
zaineb@mips.COM (Zaineb Asaf) (01/10/90)
>>From: putz@boulder.Colorado.EDU (Eric Putz) >>I am having a problem getting writeln to output a number with a decimal value >>of 0, not in the 'e' format, and am not sure if this is a compiler bug, or >>a feature of pascal. I have tried the following lines with the following >>results: writeln(1.0:1:0) gives me 1.0e+00. >>What I was hoping for was 1 when writeln was given a decimal value of 0. >>All other decimal values I have tried (> 0) have worked correctly. The >>compiler I am using is MIPS Pascal 2.0 (from RISC/os4.00 & cmplrs2.0) on >>an M2000. Any thoughts? Thanks in advance. The above statement is incorrect according to Standard Pascal. The standard states: write(e:TotalWidth:FracDigits); where the "values of TotalWidth and FracDigits shall be greater than or equal to one; it shall be an error if either value is less than one" Therefore, this problem is a user error; however, the compiler will be changed to give a runtime error if this situation will happen. Thanks for pointing out this error for us. Zaineb -- -- zaineb Asaf UUCP: {ames,decwrl,prls,pyramid}!mips!zaineb (or zaineb@mips.com) DDD: 408-991-0347 (or 408-720-1700, Ext. 347) USPS: MIPS Computer Systems, 930 Arques, Sunnyvale, CA 94086-3650
jfm@ux.acs.umn.edu (Jim Miner) (01/10/90)
In article <34282@mips.mips.COM> zaineb@mips.COM (Zaineb Asaf) writes: >>>From: putz@boulder.Colorado.EDU (Eric Putz) >>> writeln(1.0:1:0) gives me 1.0e+00. > >The above statement is incorrect according to Standard Pascal. >Therefore, this problem is a user error; however, the compiler will be changed >to give a runtime error if this situation will happen. Standard Pascal does make this an error. Interestingly, Extended Pascal permits FractDigits to be zero. The result would be "1." (not "1" as desired by Eric Putz).
ts@uwasa.fi (Timo Salmi LASK) (01/10/90)
In article <15473@boulder.Colorado.EDU> putz@boulder.Colorado.EDU (Eric Putz) writes: > >I am having a problem getting writeln to output a number with a decimal value >of 0, not in the 'e' format, and am not sure if this is a compiler bug, or >a feature of pascal. I have tried the following lines with the following >results: > writeln(1.0:1:1) gives me 1.0 > writeln(1.0:1:0) gives me 1.0e+00. >What I was hoping for was 1 when writeln was given a decimal value of 0. >All other decimal values I have tried (> 0) have worked correctly. The >compiler I am using is MIPS Pascal 2.0 (from RISC/os4.00 & cmplrs2.0) on >an M2000. Any thoughts? Thanks in advance. This is off the cuff, and concerns Turbo Pascal (so no guarantees), but try writeln(1.0:0:0) ................................................................... Prof. Timo Salmi (Site 128.214.12.3) School of Business Studies, University of Vaasa, SF-65101, Finland Internet: ts@chyde.uwasa.fi Funet: vakk::salmi Bitnet: salmi@finfun
d88-eli@nada.kth.se (Erik Liljencrantz) (01/11/90)
In article <15473@boulder.Colorado.EDU> putz@boulder.Colorado.EDU (Eric Putz) writes: >[deleted] > writeln(1.0:1:1) gives me 1.0 > writeln(1.0:1:0) gives me 1.0e+00. >[deleted] A real with no decimals... Eureka! It's an INTEGER! Try this: writeln(round(1.0):1) gives 1 This should work as long as the real number is within the integer range. -- Erik Liljencrantz | "No silly quotes!!" d88-eli@nada.kth.se | Embraquel D. Tuta