Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

Simple question - lopping off an integer

TommyCee
Beginner
848 Views

Suppose I have a 5-digit integer, and I want to recover the last 2 digits.  I just want to lop of the 1st 3 digits.  Is there an easy way to do this ?

If the variable were character, I could do this using a trim function.

What I had in mind was an indexed internal read of the variable containing the 4-digit integer but I can't get the read format right.

Any slick ideas?

0 Kudos
4 Replies
TommyCee
Beginner
728 Views

Oops.

What I had in mind was an indexed internal read of the variable containing the 4-digit integer but I can't get the read format right.

was supposed to be:

What I had in mind was an indexed internal read of the variable containing the 5-digit integer but I can't get the read format right.

0 Kudos
JohnNichols
Valued Contributor III
728 Views

What about mod(100)?

0 Kudos
TommyCee
Beginner
728 Views

That would be mod(Var,100)

Beautiful.  Now why didn't I think of that?

Thanks a lot, John!

0 Kudos
JohnNichols
Valued Contributor III
728 Views

That would be mod(Var,100) = programmer

mod(100) = pure mathematician

0 Kudos
Reply