integer function returns NaN
- From: "Tamas" <tpapp@xxxxxxxxxxxxx>
- Date: 12 Nov 2006 09:44:01 -0800
Hi,
I am trying to do a simple exercise in a Fortran book: "concatenating"
two integers, eg 19,95 => 1995.
I wrote the following:
program iconcat
integer :: a,b
read (*,*) a,b
write (*,*) cc(a,b)
end program iconcat
integer function cc(a,b)
integer, intent(in) :: a,b
integer :: m
m = floor(log10(real(b)))+1
write (*,*) 10**m*a+b ! I want this in cc ...
cc = 10**m*a+b
end function cc
When I run the program, the write statement in the function displays
the result correctly, but the write statement in the program doesn't,
eg
$ a.out
1 2
12
NaN
Maybe the error is obvious but I don't see it. The compiler is f95.
Tamas
.
- Follow-Ups:
- Re: integer function returns NaN
- From: Gordon Sande
- Re: integer function returns NaN
- Prev by Date: Re: J3's workings
- Next by Date: Re: integer function returns NaN
- Previous by thread: Sunday string puzzler
- Next by thread: Re: integer function returns NaN
- Index(es):