[haiku-development] DeskCalc Improvements (was need strtold() function)

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 30 Dec 2009 15:23:29 -0500

> I think it would be better if
> a) You used BString API instead of copying the string to a char[] buffer (for 
> example you can use BString::CountChars to get the length accounting for 
> multibyte characters),
> b) You adapted the length of the displayed number to the window size.
> For number formatting, the Locale Kit should be taking care of it, have a 
> look at headers/os/locale/FloatFormat.h . This is experimental API so :
> - Some of the functions present in the header may be buggy or do nothing at 
> all,
> - You may need things that aren't available in this API.
> In any case, please let me know and I will complete the locale kit as you 
> need.
> --
> Adrien Destugues / PulkoMandy
> http://pulkomandy.ath.cx

On point a (should use BString API) I agree, I am sure there is a
better way to do what I am trying to do using existing classes rather
than resorting to sprintf and friends on a regular char array.
However, me not being a BeOS/Haiku expert I went with what I know. If
the FloatFormat class can do a better job than sprintf() and friends
at rounding numbers and formatting them as exponentials, etc. than I
am all for it. I'll work on it and post a revised patch.

---- Long rant follows, exec summary: resizing needs work ----

On point b (adapt the length of the displayed number to the window
size) I have to disagree. It is too hard a problem and not worth it to
try and fit the result in whatever arbitrary window size is chosen. I
would have to recalculate the result as you resize which is clunky and
strange. A better method is to pick some precision and make sure that
the result fits in the display window no matter how big or small you
make the app. I don't like how when you resize the window less digits
fit. Look at any other calculator apps out there and you'll see that
they all use a fixed width and don't resize the input window.

I like the fact that you can resize the window and it scales the font
but I think it should scale the font in such a way that the result
always fits in the display window. Perhaps a solution would be to
disable resizing and have two "modes" -- small mode and big mode. You
toggle between them by clicking the double block icon in the right
hand side of the title bar. In either mode you get the same number of
digits of result but in big mode the font is, well, bigger. Another
more difficult but perhaps better solution would be to scale the font
gradually as you resize.

Either way the result has to be rounded at some point so that it fits
in the window.

John Scipione

Other related posts: