LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
Petru_Tarabuta

MinValue and MaxValue constants for integer types

Status: New

In .NET each of the integer data types provides two constant fields, named MinValue and MaxValue. These constants return the minimum and maximum values that can be stored in that data type. For example, for Int32 MinValue would return -2147483648 and MaxValue would return 2147483647.

 

1 C# min and max values.png

 

It would be nice if there would be similar constants in LabVIEW for all eight integer data types. These constants would be similar to the DBL constants that already exist: +Inf, -Inf, Machine Epsilon and NaN, and would be similar in concept to string constants such as Space Constant and End Of Line Constant.

 

The new constants could be placed in the Numeric palette, or in a new sub palette of the Numeric palette, as shown in the image below. I would be happy with any location.

 

3 Where to place the constants in LabVIEW (edited).png

 

I am aware that I can easily create constant VIs to implement this functionality, which would be very similar to how Space Constant.vi is implemented, but it would be nice if the constants were built-in.

 

My current workaround when I need the min or max values of an integer data type is to drop a numeric constant and type something like -9999999999999999 or 9999999999999999, which after Enter is pressed LabVIEW correctly coerces to the min or max value.

 

Thanks

17 Comments
Petru_Tarabuta
Active Participant

I too would prefer the constants to be primitives, to remove the risk of accidentally messing them up, but I would be happy with VIs.

I have just posted the following idea:  vi.lib VIs should be set to "Locked (no password)" - NI Community

It could potentially reduce the risk of accidentally messing up vi.lib VIs.

raphschru
Active Participant

I'm currently using the same implementation as in "Range Limits for Type.vim", but explicitly on my diagram:

raphschru_0-1638178127113.png

At least the integer type is visible, but I agree that the intention may not be understood immediately...

wiebe@CARYA
Knight of NI

What is wrong with using range limits for type?

 

I mean, besides it's name that lack min and max so you can't find it..

 

If the two outputs are really that much of a problem, split it up into 2 .vims...

raphschru
Active Participant

@ wrote:

What is wrong with using range limits for type?


On this diagram portion, without using context help, can you tell from which type I am getting the limits?

raphschru_0-1720700773085.png

 

The data type is not directly visible. Maybe a polymorphic VI with a selector label for main types (integers, floats, ...) would be better for this use case. Otherwise, this idea would help to visualize the data type on the constant directly...

wiebe@CARYA
Knight of NI

>On this diagram portion, without using context help, can you tell from which type I am getting the limits?

 

So, (suggest to) change the icon. Or (suggest to) make 2 .vims, one for min, one for max.

 

>The data type is not directly visible. Maybe a polymorphic VI with a selector label for main types (integers, floats, ...) would be better for this use case. 

 

No, it's not directly visible. You have to press CTRL+H and hover....

 

I don't think we'll get to an agreement here, but I don't mind that much (esp. for a function I use once per decade).

 

That, and we don't need NI to make this...

Petru_Tarabuta
Active Participant

Quite unrelated to the last few comments: I recently realised that a set of integer MinValue and MaxValue constants exists in the free, open-source GPower Numeric VIPM package.


The subpalette is found at: Programming >> GPower >> Numeric >> Integer Constants.

 

4 The GPower constants.png

wiebe@CARYA
Knight of NI

The forgot the min U8..64 🤣.

 

Does anyone have a use case? I don't recall ever needing this.