Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

2 Pages12>
Options
Go to last post Go to first unread
Offline qanniu  
#1 Posted : 08 November 2009 16:18:25(UTC)
qanniu

Rank: Newbie

Groups: Registered
Joined: 08/11/2009(UTC)
Posts: 3
Location: China

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.

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Andrey Ivashov  
#2 Posted : 09 November 2009 04:53:16(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,622
Man
Russian Federation

Was thanked: 1983 time(s) in 668 post(s)
No. Program have no these functions, but they will be implemented.
Offline qanniu  
#3 Posted : 09 November 2009 06:35:21(UTC)
qanniu

Rank: Newbie

Groups: Registered
Joined: 08/11/2009(UTC)
Posts: 3
Location: China

thanks,hehe.i'was finding the function all the days yesterday.by the way ,it is morning in China.
Offline marks2c  
#4 Posted : 27 December 2022 03:40:39(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
Epic dredge sorry. Functional, with all credit to @Razonar (source/author).

dec2bin.png
20221227 Dec2bin.sm (5kb) downloaded 14 time(s).

Also needed:
* set string length (ie leading zeros), and
* functions for bit field testing.

Edited by user 27 December 2022 04:33:05(UTC)  | Reason: Crediting source

Offline Jean Giraud  
#5 Posted : 27 December 2022 23:14:06(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 983 time(s) in 811 post(s)
Thanks, nice source code.
algo(col) was designed to recover matrix col(s) string(s) to values.
Cheers ... Jean.

Maths Convert-dec2bin.sm (19kb) downloaded 13 time(s).
Offline marks2c  
#6 Posted : 28 December 2022 00:19:56(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
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...

Edited by user 28 December 2022 00:33:13(UTC)  | Reason: Not specified

Offline Jean Giraud  
#7 Posted : 29 December 2022 16:46:20(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 983 time(s) in 811 post(s)
Originally Posted by: marks2c Go to Quoted Post
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.

Offline overlord  
#8 Posted : 29 December 2022 17:50:13(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,173
Turkey

Was thanked: 534 time(s) in 358 post(s)
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
Offline Jean Giraud  
#9 Posted : 29 December 2022 19:07:13(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 983 time(s) in 811 post(s)
That comes easily ... ?

countbinary.PNG
Offline marks2c  
#10 Posted : 29 December 2022 21:04:28(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
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.c...-worst-case-circuit.html

Half the tests with the +% tolerance applied the other half with the -ve tolerance applied.

Edited by user 29 December 2022 21:24:05(UTC)  | Reason: Not specified

Offline marks2c  
#11 Posted : 29 December 2022 21:12:34(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
Originally Posted by: overlord Go to Quoted Post
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.c...worst-case-circuit.html. The need is for X-Y style visualization that LTSpice can't provide.

Edited by user 29 December 2022 21:26:27(UTC)  | Reason: Not specified

Offline Razonar  
#12 Posted : 29 December 2022 21:39:13(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,481
Uruguay

Was thanked: 936 time(s) in 592 post(s)
Originally Posted by: marks2c Go to Quoted Post
...
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 (10kb) downloaded 8 time(s).

Best regards.
Alvaro.
thanks 1 user thanked Razonar for this useful post.
on 29/12/2022(UTC)
Offline marks2c  
#13 Posted : 29 December 2022 21:40:56(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
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.
Offline marks2c  
#14 Posted : 29 December 2022 21:44:09(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
Originally Posted by: Razonar Go to Quoted Post
Originally Posted by: marks2c Go to Quoted Post
...
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 (10kb) downloaded 8 time(s).

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!
Offline overlord  
#15 Posted : 30 December 2022 02:46:04(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,173
Turkey

Was thanked: 534 time(s) in 358 post(s)
Maybe this can be useful.
Regards

dec2bin.sm (4kb) downloaded 8 time(s).

2022-12-30_02-45.png
thanks 1 user thanked overlord for this useful post.
on 30/12/2022(UTC)
Offline marks2c  
#16 Posted : 30 December 2022 03:04:15(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
Originally Posted by: overlord Go to Quoted Post
Maybe this can be useful.
Regards

dec2bin.sm (4kb) downloaded 8 time(s).

2022-12-30_02-45.png


Perfect! Thank you overlord
Offline marks2c  
#17 Posted : 30 December 2022 05:03:42(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
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.

Edited by user 30 December 2022 05:09:13(UTC)  | Reason: Not specified

Offline overlord  
#18 Posted : 30 December 2022 11:09:06(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,173
Turkey

Was thanked: 534 time(s) in 358 post(s)
Originally Posted by: marks2c Go to Quoted Post
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 (7kb) downloaded 9 time(s).

2022-12-30_11-07.png
thanks 1 user thanked overlord for this useful post.
on 30/12/2022(UTC)
Offline marks2c  
#19 Posted : 30 December 2022 12:39:01(UTC)
marks2c


Rank: Advanced Member

Groups: Registered
Joined: 01/04/2020(UTC)
Posts: 85
New Zealand
Location: Wellington

Was thanked: 4 time(s) in 3 post(s)
Thank you so much overlord, that is both elegant and perfect!
Offline Jean Giraud  
#20 Posted : 30 December 2022 17:05:26(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 983 time(s) in 811 post(s)
Originally Posted by: marks2c Go to Quoted Post
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 (7kb) downloaded 9 time(s).

Users browsing this topic
2 Pages12>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.