[Flang-dev] overflow on integer output

Mehmet Erol Sanliturk m.e.sanliturk at gmail.com
Wed Aug 22 20:55:15 EDT 2018


On Thu, Aug 23, 2018 at 3:36 AM, blubee blubeeme <gurenchan at gmail.com>
wrote:

>
>
> On Thu, Aug 23, 2018 at 8:04 AM Mehmet Erol Sanliturk <
> m.e.sanliturk at gmail.com> wrote:
>
>>
>>
>> On Thu, Aug 23, 2018 at 2:36 AM, blubee blubeeme <gurenchan at gmail.com>
>> wrote:
>>
>>> I get some strange output after compiling Fortran code and running it.
>>>
>>> Example, here's a sample program; snakes and ladders.
>>> Source code: https://pastebin.com/ckS6tmfW
>>> Here's the output: https://pastebin.com/eqeTx0Xu
>>>
>>> This program calculates the area of a cylinder: https://pastebin.
>>> com/qRPkUaVa
>>> here's the output again:
>>> Enter radius and height.
>>> 21
>>> 100
>>> radius= 21.00     height=100.00     area=******
>>> Perform another calculation? y[n]
>>> quite a few test programs gives ***** for number values, do you know why?
>>>
>>> it could be something wrong with the source code that I am compiling, a
>>> problem in the way I edited the flang source and introduced a bug or I need
>>> to pass some compiler flags to get the output code to display properly or
>>> maybe something that I haven't thought about yet.
>>>
>>> Do you have any idea why?
>>>
>>> Best,
>>> Owen
>>>
>>>
>>
>>
>> First thing to come to mind is the following :
>>
>>
>>
>>
>> The value to be printed is larger than the area defined by your FORMAT
>> specifier for it .
>>
>> For example , your value is   345.75 , your FORMAT specifier for it is
>> F5.3 means  value will be printed in the form   xx.xxx .
>> Then you will see   ***** in that area because   345. is greater than 99
>> ( more than two digits ) ...
>> Increase your FORMAT specifier for the value , for example  F7.2 :
>> 345.75 will be printed correctly .
>>
>>
>>
>> Mehmet Erol Sanliturk
>>
>>
>>
>>
>>
>>
>>
>>
>> Yes, this was it; it worked for the cylinder area program. I'll have to
> see how to fix the snakes and ladders program but I appreciate the tip!
>
> Best,
> Owen
>



NaN and Inf numbers are also represented by the printed stars .

PasteBin is not accessible from Turkey due to legal blockage  . Therefore ,
it could not be possible to see your sources and results .

If you review FORMAT statement rules , and writing sufficiently large
widths for values will prevent displaying of stars when significant part
of value is not printable . A good  approach for real numbers would be
G16.8 (  8 significant digits , other 8 for the characters -.E-xxx and
blank ) .


Mehmet Erol Sanliturk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.flang-compiler.org/pipermail/flang-dev_lists.flang-compiler.org/attachments/20180823/36a23e5e/attachment-0001.html>


More information about the flang-dev mailing list