May 21, 2024, 05:54:10 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


IntSafe.inc file

Started by Andy, June 03, 2016, 07:23:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

June 03, 2016, 07:23:14 AM Last Edit: June 03, 2016, 07:50:26 AM by Andy
After looking at large numbers in my previous post (Differences between Int's and Uint's etc), I started to look into the long and long long variable in C.

Out of interest I searched the IWB include files for long, ulong long long etc, and came upon the intsafe.inc file.

To me, it makes very interesting reading, it has the min and max values for int's uint's etc, and gives a return value if there is an error when one of these variables is "out of range" of the min / max values.

I already know that "under pain of death" you should never alter any include file but...
it begs the obvious question - if you were to take a copy of this include file, save it under a different name and change the min / max values, and use it, would this "expand" the range of int's uint's etc?

It does state however - the values have been set this way to prevent overflow bugs.

Also of note - there are a lot of commented out C functions to convert one type of integer to another - int8 to uint16 etc.

Also commented out - int128 and uint128!


Does this code possibly lead the way to getting bigger numbers into an int / uint?
 
What are your thoughts on this please?

Thanks,
Andy.


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

First of all, intsafe.inc isn't used by IWBasic (with all those 'C' subroutines in there)
That file was installed as part of Sapero's "windowssdk.inc" installation.

For the sake of argument let's say it was part of IWB.
Any changes would have to be made in conjunction with all the other source code and possibly the compiler.

That's why you stay away from from the incc files and the ms inc like intsafe.inc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

June 03, 2016, 08:26:49 AM #2 Last Edit: June 03, 2016, 08:33:09 AM by Andy
Larry,

That's a fair response, I guess when it gets down to compiler lever that's the end of it.

But you can see why I was interested in this file.

So as it stands, if you want a number bigger than 18446744073709551615 you need to change to a string and use the StringMap library or write your own code to work with it.

Thanks,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

Quote from: Andy on June 03, 2016, 08:26:49 AMSo as it stands, if you want a number bigger than 18446744073709551615 you need to change to a string and use the StringMap library or write your own code to work with it.

Ever thought of using logarithms Andy?

Support Amateur Radio  -  Have a ham  for dinner!

Andy

Egil,

I'm always open to ideas as you know, but I'm lost as to how logarithms could help?

You obviously must have some logic in there, but I've never used them since school, so I wouldn't know where to start with them.

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Egil

June 04, 2016, 07:08:04 AM #5 Last Edit: June 04, 2016, 07:14:59 AM by Egil
Hi Andy,

Using logarithms is an effective, and fast, way to express very large or very small numbers or quantities, making them "managable" for calculations, by expressing these numbers as a Significand (or Mantissa) raised to a Power.
Such a way of doing things should be very familiar to programmers, using powers of two all the time.

You can see a definition of logarithms here: https://en.wikipedia.org/wiki/Common_logarithm

And if you have nothing better to do this weekend, how about a crash course:
https://www.khanacademy.org/math/algebra2/exponential-and-logarithmic-functions/introduction-to-logarithms/v/logarithms

I do not know if using logarithms will solve your coding problem, but it could be well worth a try.


Good luck!

Egil



EDIT: I haven't used logarithms myself for at least 50 years......
Support Amateur Radio  -  Have a ham  for dinner!

Andy

Egil,

Thanks, I'll get my reading head on and have a look, sounds interesting!

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.