Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Oct 7, 2020 7:54 PM
(337 views)

Hi,

I have a few sets of 32bit binary data that I want to convert it to Decimal for mathematical calculation purposes.

Can be any random 32bit binary data.

So far i have tried out these:

1. Formula(base("32bit Binary Data",2))

2. BLOB

3. Hex to Decimal (Char to Hex ("32bit Binary Data"))

32bit Binary Data:

00000000000110001101011110111000

00000000000111010000000001110100

00000000000111011001001000100000

00000000000110011001010111101000

00000000000111110001111110110101

00000000000110011110000101110000

00000000000111001000111010001000

00000000000111001000110010100000

00000000000110110111000001011110

00000000000111011101100101010000

00000000000110101100110100110100

00000000000110110011100100001011

00000000000111100111010111100110

00000000001000001111101010110100

00000000000111010010000011101111

00000000000110111110010010001000

00000000000111011011100111100100

00000000000110111010111001101100

00000000000111000111110001001100

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

@ThuongLe provided a very nice piece of JSL. Your modification into a column's formula is what is causing the issue. Try this formula. The code is a little more generic and also, it forces the "sum" variable to be the last item executed in the formula, which is what is returned to the value for the row the formula is working on

```
sum = 0;
end = Length( :Name("1F1") );
For( i = 1, i <= end, i++,
sum = sum + Num( Substr( :Name("1F1") , (end + 1) - i, 1 ) ) * 2 ^ (i - 1)
);
sum;
```

Jim

6 REPLIES 6

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to Convert a 32bit Binary data to Decimal in jmp Script

Created:
Oct 7, 2020 9:56 PM
| Last Modified: Oct 8, 2020 8:26 AM
(310 views)
| Posted in reply to message from kuanaunwei 10-07-2020

Please read this, JMP15 has a built-in function for this kind of conversion:

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to Convert a 32bit Binary data to Decimal in jmp Script

I do not have JMP15 version installed. Currently using JMP 11 Pro. So this syntax cant be applied. I have also tried out those syntax

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to Convert a 32bit Binary data to Decimal in jmp Script

Created:
Oct 7, 2020 10:47 PM
| Last Modified: Oct 7, 2020 10:49 PM
(293 views)
| Posted in reply to message from kuanaunwei 10-08-2020

I have wrote a quick script, you can modify to become a function:

```
a = "00000000000110001101011110111000";
sum = 0;
for(i = 1, i<= 32, i++,
sum = sum + num(substr(a, 33-i, 1))*2^(i-1);
);
```

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to Convert a 32bit Binary data to Decimal in jmp Script

Created:
Oct 8, 2020 12:45 AM
| Last Modified: Oct 8, 2020 8:25 AM
(277 views)
| Posted in reply to message from ThuongLe 10-08-2020

I tried out the function script it is working. However, I am trying to create a new column with the decimal data. It seems to be blank on that column 1F1-DEC.

Below is my script:

```
dt2 << New Column ("1F1", Character, Nominal, Formula(:Name( "0x905" ) || :Name( "0x904" )));
dt2 << New Column ("1F1-DEC", Numeric, Nominal, Formula(sum = 0;
for(i = 1, i<= 32, i++,
sum = sum + num(substr(:Name("1F1"), 33-i, 1))*2^(i-1);
);););
```

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

@ThuongLe provided a very nice piece of JSL. Your modification into a column's formula is what is causing the issue. Try this formula. The code is a little more generic and also, it forces the "sum" variable to be the last item executed in the formula, which is what is returned to the value for the row the formula is working on

```
sum = 0;
end = Length( :Name("1F1") );
For( i = 1, i <= end, i++,
sum = sum + Num( Substr( :Name("1F1") , (end + 1) - i, 1 ) ) * 2 ^ (i - 1)
);
sum;
```

Jim

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to Convert a 32bit Binary data to Decimal in jmp Script

@txnelsonIT WORKS!!! Thanks alot! I have been working on this for quite some time.