the function dec2bin ()

the function dec2bin () - Сообщения

#1 Опубликовано: 08.11.2009 10:18:25
qanniu

qanniu

0 сообщений из 3 понравились пользователям.

Группа: User

hi ,i'm just find smath today.i want to know is there some function like dec2bin or hex2bin...smath can you tell me thanks.
#2 Опубликовано: 08.11.2009 22:53:16
Andrey Ivashov

Andrey Ivashov

2269 сообщений из 3729 понравились пользователям.

Группа: Super Administrator

No. Program have no these functions, but they will be implemented.
#3 Опубликовано: 09.11.2009 00:35:21
qanniu

qanniu

0 сообщений из 3 понравились пользователям.

Группа: User

thanks,hehe.i'was finding the function all the days yesterday.by the way ,it is morning in China.
#4 Опубликовано: 26.12.2022 21:40:39
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Epic dredge sorry. Functional, with all credit to @Razonar (source/author).

dec2bin.png
20221227 Dec2bin.sm (4 КиБ) скачан 32 раз(а).

Also needed:
* set string length (ie leading zeros), and
* functions for bit field testing.
#5 Опубликовано: 27.12.2022 17:14:06
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Thanks, nice source code.
algo(col) was designed to recover matrix col(s) string(s) to values.
Cheers ... Jean.

Maths Convert-dec2bin.sm (18 КиБ) скачан 36 раз(а).
#6 Опубликовано: 27.12.2022 18:19:56
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

The source was repurposed from Razonar.
Interesting, thanks Jean.

Do you know a way to implement a fixed 9-bit binary counter in SMath (or display a decimal counter in fixed-length binary)? This is probably a bit too esoteric to be a feature request...
#7 Опубликовано: 29.12.2022 10:46:20
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

The source was repurposed from Razonar.
Interesting, thanks Jean.

Do you know a way to implement a fixed 9-bit binary counter in SMath (or display a decimal counter in fixed-length binary)? This is probably a bit too esoteric to be a feature request...


Sorry Collab: I have no idea yet how to counts pulse.
From recollection, such demand was not honored.
Cheers ... Jean.

#8 Опубликовано: 29.12.2022 11:50:13
overlord

overlord

547 сообщений из 1330 понравились пользователям.

Группа: Moderator

If I understood correctly;
You want a 9bit binary representation similar to 8084 cpu registers.
I must admit it is a highly specific request.

registers
#9 Опубликовано: 29.12.2022 13:07:13
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

That comes easily ... ?

countbinary.PNG
#10 Опубликовано: 29.12.2022 15:04:28
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Thanks Jean, greatly appreciated.

I should have been more clear in my request.

I'm after a 9-bit long bit-field count that I can test each bit (ie each bit has a 2^n position in the whole count) so that as the count progresses. This way each of the 9 tests will have been performed half the tests in the 0 branch and half in the 1 branch.

If it is 0 then do x, otherwise do y type of thing.

The application is worst-case circuit analysis: https://k6jca.blogspot.com/2012/07/monte-carlo-and-worst-case-circuit.html

Half the tests with the +% tolerance applied the other half with the -ve tolerance applied.
#11 Опубликовано: 29.12.2022 15:12:34
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Wrote

If I understood correctly;
You want a 9bit binary representation similar to 8084 cpu registers.
I must admit it is a highly specific request.

registers



Very close, thanks overloard.

I'm after an asynchronous 9-bit ripple-style counter that I can bit-test (or equivalent) 9 times during each loop, each time to do one of two actions half the time (ie calculated with each extreme of the tolerance) for worst-case circuit analysis.

This may be better achieved via dec2bin() with a constant 9-bit length output so that the 2^n check work consistently (ie string position tests).

FYI (reference only): https://k6jca.blogspot.com/2012/07/monte-carlo-and-worst-case-circuit.html. The need is for X-Y style visualization that LTSpice can't provide.
#12 Опубликовано: 29.12.2022 15:39:13
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: User

Wrote

...
This may be better achieved via dec2bin() with a constant 9-bit length output so that the 2^n check work consistently (ie string position tests).
...



Hi. Something like this?

Clipboard01.png

bin_counter.sm (9 КиБ) скачан 27 раз(а).

Best regards.
Alvaro.
1 пользователям понравился этот пост
Mark R Harris 29.12.2022 15:47:00
#13 Опубликовано: 29.12.2022 15:40:56
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Modification of Razonar's dec2bin() should work well.

dec2bin(p,q) where p is the bit-field length and q is the decimal number to be converted.

Check the converted string's length and then pad the front with zeros to suit.
#14 Опубликовано: 29.12.2022 15:44:09
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Wrote

Wrote

...
This may be better achieved via dec2bin() with a constant 9-bit length output so that the 2^n check work consistently (ie string position tests).
...



Hi. Something like this?

Clipboard01.png

bin_counter.sm (9 КиБ) скачан 27 раз(а).

Best regards.
Alvaro.



Cripes Alvaro. Good to see your 'calibrated-crystal-ball' and 'mind-reading skills' are as good as your awesome maths/coding skills!
#15 Опубликовано: 29.12.2022 20:46:04
overlord

overlord

547 сообщений из 1330 понравились пользователям.

Группа: Moderator

Maybe this can be useful.
Regards

dec2bin.sm (3 КиБ) скачан 29 раз(а).

2022-12-30_02-45.png
1 пользователям понравился этот пост
Mark R Harris 29.12.2022 21:03:00
#16 Опубликовано: 29.12.2022 21:04:15
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Wrote

Maybe this can be useful.
Regards

dec2bin.sm (3 КиБ) скачан 29 раз(а).

2022-12-30_02-45.png



Perfect! Thank you overlord
#17 Опубликовано: 29.12.2022 23:03:42
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

I spoke too soon! Bit-testing don't work so well on a string.

A much better idea is a column vector with each of the 9 (ie n#) elements being either a one or a zero.
#18 Опубликовано: 30.12.2022 05:09:06
overlord

overlord

547 сообщений из 1330 понравились пользователям.

Группа: Moderator

Wrote

A much better idea is a column vector


This was what I coded first, after that I made it to string.
Here is what you have asked for.

Regards

dec2bin.sm (6 КиБ) скачан 29 раз(а).

2022-12-30_11-07.png
1 пользователям понравился этот пост
Mark R Harris 30.12.2022 06:38:00
#19 Опубликовано: 30.12.2022 06:39:01
Mark R Harris

Mark R Harris

4 сообщений из 90 понравились пользователям.

Группа: User

Thank you so much overlord, that is both elegant and perfect!
#20 Опубликовано: 30.12.2022 11:05:26
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

I spoke too soon! Bit-testing don't work so well on a string.
A much better idea is a column vector with each of the 9 (ie n#) elements being either a one or a zero.


Maybe, that's what you are looking for ?

Maths Convert num2str EXTENDED.sm (6 КиБ) скачан 31 раз(а).

  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений