Difference between revisions of "Label"

From OpenFOAMWiki
 
Line 1: Line 1:
 
Variable type '''label''' is defined in OpenFOAM for storing integer data. It is widely used throughout OpenFOAM's source code wherever one might commonly expect an '''int'''.
 
Variable type '''label''' is defined in OpenFOAM for storing integer data. It is widely used throughout OpenFOAM's source code wherever one might commonly expect an '''int'''.
  
Since the C++ standard does not define the sizes of variable types in bytes, the maximum value an '''int''' and other built-in integer types can take is not strictly defined by the language. OpenFOAM defines the maximum size of '''label''' to be at least 2e+9 or 9e+18 depending on whether a 32 or a 64 bit machine is used. This is implemented by looking at the maximum values of '''int''', '''long''' and '''long long''' and using '''typedef''' to define '''label''' as a type capable to fit the desired range of values.
+
Since the C++ standard does not define the sizes of variable types in bytes, the maximum value an '''int''' and other built-in integer types can take is not strictly defined by the language. OpenFOAM defines the maximum size of '''label''' to be at least 2e+9 or 9e+18 depending on whether a 32 or a 64 bit machine is used. This is implemented by looking at the maximum values of '''int''', '''long''' and '''long long''' on the current machine and using '''typedef''' to define '''label''' as a type capable to fit the desired range of values.

Latest revision as of 13:21, 6 July 2014

Variable type label is defined in OpenFOAM for storing integer data. It is widely used throughout OpenFOAM's source code wherever one might commonly expect an int.

Since the C++ standard does not define the sizes of variable types in bytes, the maximum value an int and other built-in integer types can take is not strictly defined by the language. OpenFOAM defines the maximum size of label to be at least 2e+9 or 9e+18 depending on whether a 32 or a 64 bit machine is used. This is implemented by looking at the maximum values of int, long and long long on the current machine and using typedef to define label as a type capable to fit the desired range of values.