Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

String Formatting

Featured Replies

  • Moderator

I need to swprintf mach speed like this: .87 MHere is the swprintf line:swprintf(mach_wch, L"%0.2f M", mach_speed);How can I eliminate the leading 0 and have only the decimal value displayed?

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Author
  • Moderator

bump

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

((A:Autopilot mach hold var,mach) 100 *)%.%!02.0f! is what you want I believe. This is XML, but I think you get the drift.Mitch

How aboutint iMach;iMach = (int)(mach_speed * 100);swprintf(mach_wch, L".%2d M", iMach);Doug

  • Author
  • Moderator

>How about>>int iMach;>iMach = (int)(mach_speed * 100);>swprintf(mach_wch, L".%2d M", iMach);Thanks to both you and Mitch (with his XML example)...I had already tried a variation on this, but when I got a "kernel32.dll error," I erroneously thought it due to the L".%2d M", syntax. What my real error was is that I was trying to do the "math" in the swprintf() function itself... *:-* :~P :-bang This works fine now: UINT32 imach_speed = 0; MODULE_VAR mvmach = {MACH}; case PANEL_SERVICE_PRE_UPDATE: lookup_var (&mvmach); imach_speed = (FS_MACH(mvmach.var_value.n))*100; case PANEL_SERVICE_PRE_DRAW: /* MACH Digital Display */ WCHAR mach_wch[10] = L""; swprintf(mach_wch, L".%02d M", imach_speed); RectF rectFmach(0.0f, -1.0f, 68.0f, 26.0f); stringFormat.SetAlignment(StringAlignmentNear); if (showmach == 1) { graphics.FillRectangle(&blackBrush, rectFmach); graphics.DrawString(mach_wch, -1, &Arial22, rectFmach, &stringFormat, &whiteBrush); }http://forums.avsim.net/user_files/139884.jpg

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

yeah, using a %f specifier would not allow it.If a period is specified there's always one digit printed before the period. Unless no number follows the period in which case there's no period printed but the value is rounded.Regards.Ernie.

ea_avsim_sig.jpg

Bill,It struck me, after I posted, that you will need to trap the possibility of the aircraft exceeding Mach 1. The existing code (as well as my example) will display that as ".100 M" rather than "1.00 M"Doug

  • Author
  • Moderator

>Bill,>>It struck me, after I posted, that you will need to trap the>possibility of the aircraft exceeding Mach 1. The existing>code (as well as my example) will display that as ".100 M">rather than "1.00 M"Doug, if the Citation XLS exceeds Mach 1, I should think the last thing they'll worry about is whether the display is correct... ;)Top speed is 0.87 M.

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.