Uppercase hex format?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Uppercase hex format?

Rik-4
All,

When using "format hex" the output uses lowercase letters a-f to represent
10-15.  This is fine, and compatible with Matlab.

However, in my background as an electrical engineer, I prefer to see this
as uppercase letters A-F.  Is there any interest in extending Octave to
support this?

We already have forms like "short e" and "short E" which switch the
exponent in scientific notation from lower case to upper case.

I made a rough patch which uses "format HEX" to switch to uppercase letters
and it is as simple as adding the flag std::ios::uppercase to the output
stream operator '<<' in C++.

--Rik

Reply | Threaded
Open this post in threaded view
|

Re: Uppercase hex format?

Michael Godfrey


On 10/10/19 7:23 PM, Rik wrote:

> All,
>
> When using "format hex" the output uses lowercase letters a-f to represent
> 10-15.  This is fine, and compatible with Matlab.
>
> However, in my background as an electrical engineer, I prefer to see this
> as uppercase letters A-F.  Is there any interest in extending Octave to
> support this?
>
> We already have forms like "short e" and "short E" which switch the
> exponent in scientific notation from lower case to upper case.
>
> I made a rough patch which uses "format HEX" to switch to uppercase letters
> and it is as simple as adding the flag std::ios::uppercase to the output
> stream operator '<<' in C++.
>
> --Rik
>
I definitely vote for this. (For us engineers...)

Michael

Reply | Threaded
Open this post in threaded view
|

Re: Uppercase hex format?

apjanke-floss


On 10/10/19 3:21 PM, Michael D Godfrey wrote:

>
>
> On 10/10/19 7:23 PM, Rik wrote:
>> All,
>>
>> When using "format hex" the output uses lowercase letters a-f to
>> represent
>> 10-15.  This is fine, and compatible with Matlab.
>>
>> However, in my background as an electrical engineer, I prefer to see this
>> as uppercase letters A-F.  Is there any interest in extending Octave to
>> support this?
>>
>> We already have forms like "short e" and "short E" which switch the
>> exponent in scientific notation from lower case to upper case.
>>
>> I made a rough patch which uses "format HEX" to switch to uppercase
>> letters
>> and it is as simple as adding the flag std::ios::uppercase to the output
>> stream operator '<<' in C++.
>>
>> --Rik
>>
> I definitely vote for this. (For us engineers...)
>
> Michael
>


Us hackers coming from the C/C++ world might also appreciate having this
option. I also vote for this.

Andrew

Reply | Threaded
Open this post in threaded view
|

Re: Uppercase hex format?

nrjank


On Thu, Oct 10, 2019 at 15:37 Andrew Janke <[hidden email]> wrote:


On 10/10/19 3:21 PM, Michael D Godfrey wrote:
>
>
> On 10/10/19 7:23 PM, Rik wrote:
>> All,
>>
>> When using "format hex" the output uses lowercase letters a-f to
>> represent
>> 10-15.  This is fine, and compatible with Matlab.
>>
>> However, in my background as an electrical engineer, I prefer to see this
>> as uppercase letters A-F.  Is there any interest in extending Octave to
>> support this?
>>
seems like a fairly low risk expansion of capability. Is there any case someone can think of where this would cause a conflict of some kind?  Will it need to extend to any other I/o or math functions?

Reply | Threaded
Open this post in threaded view
|

Re: Uppercase hex format?

Mike Miller-4
On Thu, Oct 10, 2019 at 20:01:27 -0400, Nicholas Jankowski wrote:
> seems like a fairly low risk expansion of capability. Is there any case
> someone can think of where this would cause a conflict of some kind?  Will
> it need to extend to any other I/o or math functions?

One risk is that Matlab's format command is case insensitive. The
command "format HEX" is identical to "format hex". Some day someone may
ask for Octave's format command to accept case insensitive arguments for
compatibility.

I generally think that having different options that only differ in case
is a bad interface. A better option might be something like "format
hexupper" or "format hex upper".

--
mike

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Uppercase hex format?

apjanke-floss
In reply to this post by nrjank


On 10/10/19 8:01 PM, Nicholas Jankowski wrote:


On Thu, Oct 10, 2019 at 15:37 Andrew Janke <[hidden email]> wrote:


On 10/10/19 3:21 PM, Michael D Godfrey wrote:
>
>
> On 10/10/19 7:23 PM, Rik wrote:
>> All,
>>
>> When using "format hex" the output uses lowercase letters a-f to
>> represent
>> 10-15.  This is fine, and compatible with Matlab.
>>
>> However, in my background as an electrical engineer, I prefer to see this
>> as uppercase letters A-F.  Is there any interest in extending Octave to
>> support this?
>>
seems like a fairly low risk expansion of capability. Is there any case someone can think of where this would cause a conflict of some kind?  Will it need to extend to any other I/o or math functions?

One risk is that some code might be setting a format and then using "evalc(...)" to capture output and using the results programmatically. (IMHO this is a terrible code pattern, but it is indeed something you can do...)

I think this is still very low risk if the uppercase behavior is activated by an Octave-specific extension to the "format hex" command that you have to explicitly request; there's no way any ported Matlab code would be doing that.

Andrew
Reply | Threaded
Open this post in threaded view
|

Re: Uppercase hex format?

apjanke-floss
In reply to this post by Mike Miller-4


On 10/10/19 8:16 PM, Mike Miller wrote:

> On Thu, Oct 10, 2019 at 20:01:27 -0400, Nicholas Jankowski wrote:
>> seems like a fairly low risk expansion of capability. Is there any case
>> someone can think of where this would cause a conflict of some kind?  Will
>> it need to extend to any other I/o or math functions?
>
> One risk is that Matlab's format command is case insensitive. The
> command "format HEX" is identical to "format hex". Some day someone may
> ask for Octave's format command to accept case insensitive arguments for
> compatibility.
>
> I generally think that having different options that only differ in case
> is a bad interface. A better option might be something like "format
> hexupper" or "format hex upper".
>

Oh, yeah: I didn't notice that this was activated by a case change in
the "format hex" argument.

This is exacerbated by the fact that the Matlab documentation for
"format" actually lists the argument options in upper case in the first
place, so "HEX" instead of "hex" is what they say to do if you want to
get the normal "format hex" behavior.

Definitely "format hexupper" or "format hexu" or "format hex upper",
instead of "format hex" vs "format HEX".

Cheers,
Andrew