- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
do k=1,10
ibip=0
do j=0,15
if(btest(k,j))ibip=ibip+1
enddo
write(6,*)k,ibip
enddo
stop
end
Version 12.0.X give wrong results...version 11 is ok.
ibip=0
do j=0,15
if(btest(k,j))ibip=ibip+1
enddo
write(6,*)k,ibip
enddo
stop
end
Version 12.0.X give wrong results...version 11 is ok.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The maximum bit positions for maximum integer, k=10, will be 4 that is j=0,3. This is the possible reason because of which you are getting wrong answer. I checked your code by ifort 12.0.3.167and it is giving wrong result because of wrong declaration. But, the gfortran compiler behaves differently and gives right answer with the present form of the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> it is giving wrong result because of wrong declaration
What "wrong declaration"? The second argument to the intrinsic function btest(i, pos) is required to satisfy 0 pos < bit_size(i). Do you think there is a violation of this requirement in the test program?
What "wrong declaration"? The second argument to the intrinsic function btest(i, pos) is required to satisfy 0 pos < bit_size(i). Do you think there is a violation of this requirement in the test program?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This may be bug as I see some older posts. But this can be circumvented if we declare j = 0, 3. Moreover, I also noticed that the results are coming right up to j=0, 10. If we give j=0, 11 results go wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't see anything wrong with the source as posted. This is pretty much the exact same program as in the other thread. Clearly both of you read this somewhere - where?

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page