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.
|
|
|
|
Rank: Administration Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member Joined: 11/07/2008(UTC) Posts: 1,622 Was thanked: 1983 time(s) in 668 post(s)
|
No. Program have no these functions, but they will be implemented.
|
|
|
|
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.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 01/04/2020(UTC) Posts: 85 Location: Wellington Was thanked: 4 time(s) in 3 post(s)
|
Epic dredge sorry. Functional, with all credit to @Razonar (source/author). 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
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 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).
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 01/04/2020(UTC) Posts: 85 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
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
Originally Posted by: marks2c 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.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,173 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.
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
That comes easily ... ?
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 01/04/2020(UTC) Posts: 85 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.htmlHalf 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
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 01/04/2020(UTC) Posts: 85 Location: Wellington Was thanked: 4 time(s) in 3 post(s)
|
Originally Posted by: overlord If I understood correctly; You want a 9bit binary representation similar to 8084 cpu registers. I must admit it is a highly specific request. 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
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,481 Was thanked: 936 time(s) in 592 post(s)
|
Originally Posted by: marks2c ... 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? bin_counter.sm (10kb) downloaded 8 time(s).Best regards. Alvaro.
|
1 user thanked Razonar for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 01/04/2020(UTC) Posts: 85 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.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 01/04/2020(UTC) Posts: 85 Location: Wellington Was thanked: 4 time(s) in 3 post(s)
|
Originally Posted by: Razonar Originally Posted by: marks2c ... 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? 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!
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,173 Was thanked: 534 time(s) in 358 post(s)
|
Maybe this can be useful. Regards dec2bin.sm (4kb) downloaded 8 time(s).
|
1 user thanked overlord for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 01/04/2020(UTC) Posts: 85 Location: Wellington Was thanked: 4 time(s) in 3 post(s)
|
Originally Posted by: overlord Maybe this can be useful. Regards dec2bin.sm (4kb) downloaded 8 time(s). Perfect! Thank you overlord
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 01/04/2020(UTC) Posts: 85 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
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,173 Was thanked: 534 time(s) in 358 post(s)
|
Originally Posted by: marks2c 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).
|
1 user thanked overlord for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 01/04/2020(UTC) Posts: 85 Location: Wellington Was thanked: 4 time(s) in 3 post(s)
|
Thank you so much overlord, that is both elegant and perfect!
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
Originally Posted by: marks2c 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).
|
|
|
|
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.