Bitcheck on a Integer

guidorobben
Member Posts: 157
Is there a way to convert a intger to a bit?
Guido
Guido
0
Comments
-
Even a boolean is 4 bytes (native navision). The corresponding SQL data type of a boolean is TINYINT, which is 1 byte. I guess this is the smallest you can go ... .
(At least if nobody has another suggestion? - I'm not sure, you see ...)
You can convert to a boolean with:EVALUATE(myBool, myInteger);
0 -
If using SQL option, you can Design a table in Enterprise Manager (for each company) and change the Data Type To bit.
By changing Navision boolean (SQL tinyint) to SQL bit you would probably loose nothing, since only 0 and 1 can be entered in Navision.
By changing Navision integer (SQL int) to SQL bit you will convert all nonzero values to 1.
In my opinion you should not change data type in SQL, since you can produce unpredictable situations. And changes to your system get messy. The size of storage place isn't probably a problem. If you want user to limit to 0 and 1, you can do it another way. (Using code OnValidate, using property ValuesAllowed...)®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
You probably want to view an integer value in binary representation. I don't know any command to do it. You have to create your function (e.g. BitSet, BitTest) and manipulate with integer value by dividing by 2.0
-
You probably want to view an integer value in binary representation. I don't know any command to do it. You have to create your function (e.g. BitSet, BitTest) and manipulate with integer value by dividing by 2.
Yep that's it. So there's no way to to this that build it yourself...
Guido0 -
yep...
ToBinary(liNumber : Integer) ltBinary : Text[50] WHILE liNumber > 0 DO BEGIN ltBinary := FORMAT(liNumber MOD 2) + ltBinary; liNumber := liNumber DIV 2; END;
®obi
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯0 -
This is the thing I build to check the bit values. Thanx to RobertMo for his beginning...
If somebody has question/comments let me know...
You can use it like this:
HasBit(18,2)
This will result in True
HasBit(5,2)
This will result in False
PROCEDURE HasBit(Source : Integer;Bit : Integer) : Boolean;
VAR
BitSource: Text[32];
BitBit: Text[32];
I: Integer;
BEGIN
IF Source < Bit THEN EXIT(FALSE);
// Create Bit list Source in Reversed order
WHILE Source > 0 DO BEGIN
BitSource := BitSource + FORMAT(Source MOD 2);
Source := Source DIV 2;
END;
// MESSAGE(BitSource);
// Create Bitlist for the bit value in Reversed order
WHILE Bit > 0 DO BEGIN
BitBit := BitBit + FORMAT(Bit MOD 2);// + BitBit;
Bit := Bit DIV 2;
END;
// MESSAGE(BitBit);
FOR I := 1 TO STRLEN(BitBit) DO
BEGIN
IF BitBit = '1' THEN EXIT(BitSource = '1');
END;
END;0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions