- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am converting some Mathcad code to Fortranroutinesand need a reliable method of storing Integers as reals and then converting them back to Integer for use as array subscripts, without having rounding problems with the reals. Suggestions would be appreciated.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't read between your lines, so I may be missing your point. A real data type can hold integers exactly, up to intval <= 1/EPSILON(realval). If you can use selected_int_kind and selected_real_kind, you can choose data types, within limits, such that all the integers fit in the real data type.
For your real to integer conversions, you may want
intval = nint(realval,kind(intval))
For your real to integer conversions, you may want
intval = nint(realval,kind(intval))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks.

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