hi,
i'm trying to convert arbitrary hexadecimal numbers to decimal ones, preferably with vanilla objects.
while it's easy to do it the other way round with [makefilename], i'm facing a peculiar problem from hex --> dec when the letter E is present and followed by a number.
my approach would be to take a hex number, interpret it as a symbol, get each hex-digit's ascii value, and do the conversion from there
let's take the hex number 27E5 as an example
no matter what sort of conversion i try ([symbol], [list tosymbol], [makefilename], [fudiformat]), PD always interprets it as a decimal number with an exponent, so
[27E5( | makefilename %s | [print]
will give me "symbol 2.7e+006" in the console (or in a symbol atom).
(of course a number like 27A5 or 275E expands with no problem to a straight symbol and can then be ascii-fied)
is there anything i can do to make PD take 27E5 as a literal symbol rather than a float ?
best
oliver
maybe this can help you make a full vanilla abstraction
https://github.com/porres/pd-else/blob/master/Classes/Abstractions/hex2dec.p...
Em ter., 19 de jan. de 2021 às 21:22, oliver oliver@klingt.org escreveu:
hi,
i'm trying to convert arbitrary hexadecimal numbers to decimal ones, preferably with vanilla objects.
while it's easy to do it the other way round with [makefilename], i'm facing a peculiar problem from hex --> dec when the letter E is present and followed by a number.
my approach would be to take a hex number, interpret it as a symbol, get each hex-digit's ascii value, and do the conversion from there
let's take the hex number 27E5 as an example
no matter what sort of conversion i try ([symbol], [list tosymbol], [makefilename], [fudiformat]), PD always interprets it as a decimal number with an exponent, so
[27E5( | makefilename %s | [print]
will give me "symbol 2.7e+006" in the console (or in a symbol atom).
(of course a number like 27A5 or 275E expands with no problem to a straight symbol and can then be ascii-fied)
is there anything i can do to make PD take 27E5 as a literal symbol rather than a float ?
best
oliver
-- \\\\\\\\\\\\\\\\\\\\\\\\\\\\ /////////////// http://pendler.klingt.org ////////////// \\\\\\\\ http://oliver.klingt.org \\\\\\\ ////////////////////////////////////////////////////////
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
sorry, now that I read your email, I see you know about the solution I provide, and yeah, I now see the same issue.
But in my abstraction, if I convert "0x27E5" instead of "27E5", it works! I'll have to see why this is happening...
Em ter., 19 de jan. de 2021 às 21:22, oliver oliver@klingt.org escreveu:
hi,
i'm trying to convert arbitrary hexadecimal numbers to decimal ones, preferably with vanilla objects.
while it's easy to do it the other way round with [makefilename], i'm facing a peculiar problem from hex --> dec when the letter E is present and followed by a number.
my approach would be to take a hex number, interpret it as a symbol, get each hex-digit's ascii value, and do the conversion from there
let's take the hex number 27E5 as an example
no matter what sort of conversion i try ([symbol], [list tosymbol], [makefilename], [fudiformat]), PD always interprets it as a decimal number with an exponent, so
[27E5( | makefilename %s | [print]
will give me "symbol 2.7e+006" in the console (or in a symbol atom).
(of course a number like 27A5 or 275E expands with no problem to a straight symbol and can then be ascii-fied)
is there anything i can do to make PD take 27E5 as a literal symbol rather than a float ?
best
oliver
-- \\\\\\\\\\\\\\\\\\\\\\\\\\\\ /////////////// http://pendler.klingt.org ////////////// \\\\\\\\ http://oliver.klingt.org \\\\\\\ ////////////////////////////////////////////////////////
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Em ter., 19 de jan. de 2021 às 23:58, Alexandre Torres Porres < porres@gmail.com> escreveu:
sorry, now that I read your email, I see you know about the solution I provide, and yeah, I now see the same issue.
But in my abstraction, if I convert "0x27E5" instead of "27E5", it works! I'll have to see why this is happening...
yeah, of course, for Pd 27E5 is the same as "2700000" and I don't think there's a way to convert the float "27E5" to a literal symbol "27E5". The way to do this is use a symbol input directly, which makes sense, since you want to convert things like "FF".
It's funny that these days I updated by abstraction to also accept floats (though it hasn't been updated as part of a release yet). I tought "what could go wrong". Well, here it is, of course it's a terrible idea!
so, just have symbol inputs like I used to have and will revert back to that state again :)
On Wed, 2021-01-20 at 01:19 +0100, oliver wrote:
is there anything i can do to make PD take 27E5 as a literal symbol rather than a float ?
Roman