Post Reply 
Base Conversion
05-12-2016, 07:26 PM (This post was last modified: 06-08-2016 06:47 AM by Stevetuc.)
Post: #12
RE: Base Conversion
(05-12-2016 07:12 PM)salvomic Wrote:  
(05-12-2016 06:49 PM)Stevetuc Wrote:  Salvo, This works with both Baseconv(255) and Baseconv(#255d)
Hopefully no introduced bugs!

hi Stevetuc,
it's ok to overcome the error but there is a last thing to solve:
Baseconv(255) is seen always as it was Baseconv(#255h), as hex, so
Baseconv(255) -> Hex -> Input return #255h and not the correct #FFh, I think that user mean 255 *is* decimal, otherwise it would have write #255h (597d) :-)
With this code
Code:
IF LEFT(STRING(in),1) ≠ "#" THEN in:=EXPR("#"+in+"d") END;
it works interpreting 255 as decimal.
But... But if the user inputs
Baseconv(#255) still the code interprets as #255h (it adds the "h" for hex) :-)
In this case, maybe the user really means to say "#255h", otherwise he/she doesn't put the "#" first...

However, besides that, it's ok!
thank you
Salvo


I think what happens is that it assumes the number is in whatever the default base is set to in settings. Mine is in decimal so it treats unqualified numbers as such. Hard coding to decimal will allow to override the settings but I guess this may not always produce the desired result

Thanks for helping me debug this!
Steve
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Base Conversion - Stevetuc - 05-12-2016, 06:46 AM
RE: Base Conversion - jrozsas - 05-12-2016, 09:21 AM
RE: Base Conversion - salvomic - 05-12-2016, 09:55 AM
RE: Base Conversion - jrozsas - 05-12-2016, 01:10 PM
RE: Base Conversion - salvomic - 05-12-2016, 01:13 PM
RE: Base Conversion - Stevetuc - 05-12-2016, 02:11 PM
RE: Base Conversion - salvomic - 05-12-2016, 02:27 PM
RE: Base Conversion - Stevetuc - 05-12-2016, 04:42 PM
RE: Base Conversion - salvomic - 05-12-2016, 04:52 PM
RE: Base Conversion - Stevetuc - 05-12-2016, 06:49 PM
RE: Base Conversion - salvomic - 05-12-2016, 07:12 PM
RE: Base Conversion - Stevetuc - 05-12-2016 07:26 PM
RE: Base Conversion - salvomic - 05-12-2016, 07:31 PM
RE: Base Conversion - Eddie W. Shore - 06-07-2016, 01:08 PM
RE: Base Conversion - Stevetuc - 06-09-2016, 03:22 PM
RE: Base Conversion - salvomic - 06-09-2016, 03:33 PM
RE: Base Conversion - Stevetuc - 06-10-2016, 09:19 AM
RE: Base Conversion - JDW - 08-16-2018, 03:56 AM
RE: Base Conversion - Tyann - 08-16-2018, 05:36 AM
RE: Base Conversion - JDW - 08-16-2018, 10:02 AM
RE: Base Conversion - Stevetuc - 08-16-2018, 11:21 AM
RE: Base Conversion - JDW - 08-16-2018, 11:43 AM
RE: Base Conversion - Stevetuc - 08-16-2018, 12:19 PM
RE: Base Conversion - JDW - 08-17-2018, 01:46 AM
RE: Base Conversion - Stevetuc - 08-17-2018, 04:13 AM
RE: Base Conversion - salvomic - 06-10-2016, 09:51 AM
RE: Base Conversion - Stevetuc - 06-11-2016, 07:53 AM



User(s) browsing this thread: 1 Guest(s)