abdulsulo
- 13
- 0
Hello there. I am trying to take a power of 1/7 of one variable but as a default it gives me 1 similar to if I was taking power of 0. How can I solve this problem. Thanks
The discussion revolves around the issue of taking the 1/7 power of a variable in programming, specifically in Fortran. Participants explore the behavior of integer versus floating-point division and its implications in calculations.
Participants generally agree on the confusion caused by integer versus floating-point division, but there are differing opinions on programming language design and the frequency of using integer division.
The discussion highlights limitations in understanding division behavior in programming, particularly regarding the treatment of integer and floating-point operations. There are also references to historical programming practices and potential pitfalls for beginners.
Do I=2,N,1
X1=(Yr(I)/R)
X2=X1**(1/7)
Ua(I)=Um*X2
END DO
Your hint gave me an idea and I think I solved the problem. I put 1./7. to the equation and problem solved. Didn't notice it would roll it down to 0. Thank you very much.DrClaude said:What exactly did you write? I suspect that the 1/7 is being treated as an integer operation and rounded to 0.
I use integer division often. This operation and the modulus operation are useful in converting days to weeks and days, ounces to pounds and ounces, making change, and many other applications.rumborak said:If I ever designed a programming language, floating point division would be the default behavior. I do not recall the last time I actually used integer division.