NAMEunsafeconversion - Routines to override types for simple valuesDESCRIPTIONThis class contains routines that change type of bitpatterns. They are useful when interfacing to external routines or doing I/O to unformatted interfaces. It can for example copy a real number to an integer variable and vice versa without changing the actual bitpattern.EXAMPLEexternalclassUnsafeConversion;ref(UnsafeConversion)Override;integerBitpattern;realX;Override:-newUnsafeConversion;Bitpattern:=<readasintegerfrompipe>;X:=Override.ItoReal(Bitpattern);AUTHORBoris Magnusson, Lund Institute of Technology.USEDeclaration: external class UnsafeConversion; Compilation: simcomp -L=/usr/local/simulabin -I=simlib Linking: simld ... -lsimlibDETAILEDINTERFACEclassUnsafeConversion;This class contains routines that change type on bitpatterns. They are useful when interfacing to external routines or doing I/O to unformatted interfaces. If for example a bitpattern has been obtained as an integer, but it is know that the bitpattern should really be interpreted as a real. Accordingly, a program can use this class to output a real number as an integer bitpattern. The routines converting to/from 16-bit integers can be useful when interfacing to C-programs that use this packed form in e. g. structs or in arrays, since Simula is using 32bit integers also for 16-bit values. Supers: - Kind: Instantiable Init: none Sequencing:(ItoSS/SStoI/ItoReal/RealtoI/IItoLong/LongtoII)*OPERATIONSItoSSprocedureItoSS(I,s1_result,s2_result);names1_result,s2_result;integeri;shortintegers1_result;!:=I//2**16,signextended;shortintegers2_result;!:=mod(I,2**16),signextended;Split an 32-bit integer into two 16-bit intergers containing the most significant(s1) and least significant(s2) bits. Both results are sign extended.SStoIintegerprocedureSStoI(s1,s2);shortintegers1,s2;Combine two 16-bit integers into one 32-bit integer. Returns s1*2**16+s2, except that the numbers are masked logically AND together.ItoRealrealprocedureItoReal(Bits);integerBits;!Formallyanintegerbutbitpatternofareal;This procedure returns the same bitpattern as given as parameter, but formally as a real. Can be used to circumvent Simula typechecking of simple values.RealtoIintegerprocedureRealtoI(Bits);realBits;!Formallyarealbutbitpatternofaninteger;This procedure returns the same bitpattern as given as parameter, but formally as an integer. Can be used to circumvent Simula typechecking of simple values.IItoLonglongrealprocedureIItoLong(I1,I2);integerI1,I2;Combine two 32-bit integers into one 64-bit long real. This procedure returns the bitpatterns given to it, changing the type to long real. I1 is the high order bits of the representation of a long real (including the sign bit and exponent) while I2 is the low order bits of the mantissa.LongtoIIprocedureLongtoII(Bits,I1,I2);nameI1,I2;LongrealBits;integerI1,I2;Splits one 64-bit long real into two 32-bit integer bit- patterns. This procedure returns the bitpattern given to it. I1 is the high order bits of the representation of a long real (including the sign bit and exponent) while I2 is the low order bits of the mantissa.