ReactOS 0.4.15-dev-7113-g9ea2222
muldiv.c File Reference
#include <k32.h>
Include dependency graph for muldiv.c:

Go to the source code of this file.

Functions

INT WINAPI MulDiv (INT nNumber, INT nNumerator, INT nDenominator)
 

Function Documentation

◆ MulDiv()

INT WINAPI MulDiv ( INT  nNumber,
INT  nNumerator,
INT  nDenominator 
)

Definition at line 25 of file muldiv.c.

28{
30 LONG Negative;
31
32 /* Find out if this will be a negative result */
33 Negative = nNumber ^ nNumerator ^ nDenominator;
34
35 /* Turn all the parameters into absolute values */
36 if (nNumber < 0) nNumber *= -1;
37 if (nNumerator < 0) nNumerator *= -1;
38 if (nDenominator < 0) nDenominator *= -1;
39
40 /* Calculate the result */
41 Result.QuadPart = Int32x32To64(nNumber, nNumerator) + (nDenominator / 2);
42
43 /* Now check for overflow */
44 if (nDenominator > Result.HighPart)
45 {
46 /* Divide the product to get the quotient and remainder */
48 (ULONG)nDenominator,
49 (PULONG)&Result.HighPart);
50
51 /* Do the sign changes */
52 if ((LONG)Result.LowPart >= 0)
53 {
54 return (Negative >= 0) ? (LONG)Result.LowPart : -(LONG)Result.LowPart;
55 }
56 }
57
58 /* Return overflow */
59 return - 1;
60}
NTSYSAPI UINT WINAPI RtlEnlargedUnsignedDivide(ULONGLONG, UINT, UINT *)
#define Int32x32To64(a, b)
long LONG
Definition: pedump.c:60
uint32_t * PULONG
Definition: typedefs.h:59
uint32_t ULONG
Definition: typedefs.h:59
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by _Success_(), AddFontStyle(), AdvAppearanceDlgProc(), AVIFILE_CreateAVITempFile(), AVIFILE_LoadSunFile(), AVIFILE_SaveFile(), AVIFILE_UpdateInfo(), AviMux_Run(), AVISaveVW(), calc_thumb_dimensions(), centmm_to_twips(), CFn_WMInitDialog(), check_vertical_metrics(), compare_font(), convert_sizel(), ConvertRect(), CreateBoldFont(), CreateMonospaceFont(), CreateTitleFont(), ctrl_container_resize(), customctrl_resize(), devunits_to_twips(), dialog_choose_font(), DIALOG_CreateControls32(), DIALOG_CreateIndirect(), dialog_handle_event(), dialogunits_to_pixels(), Display_SetTypeFace(), dotest_spi_iconhorizontalspacing(), dotest_spi_iconverticalspacing(), DoTestEntry(), DrawBackgroundPreview(), DumpFont(), EMF_SetMapMode(), EmfEnumProc(), export_welcome_dlg_proc(), FancyLogoffOnInit(), get_bar_position(), get_dialog_font_point_size(), get_image_part_size(), get_led_size(), CSysPagerWnd::GetSize(), getwinmetafilebits(), HEADER_DrawItem(), HeightFromPointSize(), hf_to_cf(), HLPFILE_BrowseParagraph(), IAVIFile_fnInfo(), ICMStream_fnCreate(), import_welcome_dlg_proc(), init_custom_controls(), InitInstance(), insert_static_object(), IntScrollGetScrollBarRect(), joystick_map_axis(), LISTBOX_SetTabStops(), load_dib(), LoadDialog(), LoadDialogCtrls(), LogicalSizeToPointSize(), font::MakeFont(), MapDialogRect(), MCIAVI_mciStatus(), MCIWndProc(), ME_DrawOLE(), ME_GetBorderPenWidth(), ME_GetOLEObjectSize(), ME_HandleMessage(), ME_ScrollAbs(), ME_UpdateScrollBar(), MFDRV_StretchBlt(), MonSelGetMonitorFont(), msi_dialog_add_font(), msi_dialog_adjust_dialog_pos(), msi_dialog_get_sans_serif_height(), msi_dialog_scale_unit(), MSSTYLES_GetFont(), OleCreatePropertyFrameIndirect(), OLEFontImpl_get_Size(), OleMetafilePictFromIconAndLabel(), OLEPictureImpl_LoadAPM(), OnInitDialog(), OutputWorker::OutputWorker(), pixels_to_dialogunits(), PlayEnhMetaFileRecord(), PointSizeFromHeight(), PointSizeToLogicalSize(), populate_size_list(), prepare_png_alpha(), PROPSHEET_AdjustSize(), realize_font(), save_dib(), SaveCurrentValues(), scale_point_dpi(), scale_rect_dpi(), SCROLL_GetThumbVal(), SetMessageFont(), SetWinMetaFileBits(), ShutdownOnFriendlyInit(), SoftModalMessageBox(), stream_out_graphics(), test_capture(), test_ChooseFontA(), test_clock(), test_data_cache_dib_contents_stream(), test_dc_layout(), test_dpi_mapping(), test_dpi_stock_objects(), test_DrawTextCalcRect(), test_emf_BitBlt(), test_GetSystemMetrics(), test_height(), test_himetric(), test_metrics_for_dpi(), test_padding(), test_world_transform(), test_worst_case(), ThemeCalculateCaptionButtonsPos(), twips_to_centmm(), twips_to_pixels(), update_caret(), update_control_text(), UpdateControls(), CTextEditWindow::UpdateFont(), UXTHEME_DrawImageBackground(), WAVE_ConvertByteToTimeFormat(), WAVE_ConvertTimeFormatToByte(), WebBrowser_OleObject_Init(), widGetPosition(), WinPrev_OnDisplayChange(), wodGetPosition(), xpixels_to_himetric(), and ypixels_to_himetric().