kicad/pcbnew/dialogs
Dick Hollenbeck c24863c078 // Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did.  This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.


#include <stdio.h>
#include <assert.h>
#include <limits.h>

//-----<KiROUND KIT>------------------------------------------------------------

/**
 * KiROUND
 * rounds a floating point number to an int using
 * "round halfway cases away from zero".
 * In Debug build an assert fires if will not fit into an int.
 */

#if defined( DEBUG )

// DEBUG: a macro to capture line and file, then calls this inline

static inline int KiRound( double v, int line, const char* filename )
{
    v = v < 0 ? v - 0.5 : v + 0.5;
    if( v > INT_MAX + 0.5 )
    {
        printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
    }
    else if( v < INT_MIN - 0.5 )
    {
        printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
    }
    return int( v );
}

#define KiROUND( v )    KiRound( v, __LINE__, __FILE__ )

#else

// RELEASE: a macro so compile can pre-compute constants.

#define KiROUND( v )  int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )

#endif


//-----</KiROUND KIT>-----------------------------------------------------------

// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );


int main( int argc, char** argv )
{
    for( double d = double(INT_MAX)-1;  d < double(INT_MAX)+8;  d += 2.0 )
    {
        int i = KiROUND( d );

        printf( "t: %d  %.16g\n", i, d );
    }

    return 0;
}
2012-04-19 01:55:45 -05:00
..
dialog_SVG_print.cpp Removal of internal units. 2012-04-16 19:31:29 -04:00
dialog_SVG_print.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_SVG_print_base.cpp Fix typo errors and make translations more easy. 2011-10-03 21:11:09 +02:00
dialog_SVG_print_base.fbp Fix typo errors and make translations more easy. 2011-10-03 21:11:09 +02:00
dialog_SVG_print_base.h Fix typo errors and make translations more easy. 2011-10-03 21:11:09 +02:00
dialog_block_options_base.cpp Pcbnew: Fix a very minor issue in left toolbar. Add option in dialog bloc to move,copy ... items on invisible layers or not. 2011-03-07 13:28:14 +01:00
dialog_block_options_base.fbp Fix a serious bug in EDA_RECT::Intersects 2012-04-16 14:56:01 +02:00
dialog_block_options_base.h Pcbnew: Fix a very minor issue in left toolbar. Add option in dialog bloc to move,copy ... items on invisible layers or not. 2011-03-07 13:28:14 +01:00
dialog_cleaning_options.cpp switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_cleaning_options.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_cleaning_options_base.cpp Code cleaning. Also fix gcc 4.5 compil warnings. 2010-11-21 19:28:32 +01:00
dialog_cleaning_options_base.fbp Code cleaning. Also fix gcc 4.5 compil warnings. 2010-11-21 19:28:32 +01:00
dialog_cleaning_options_base.h Code cleaning. Also fix gcc 4.5 compil warnings. 2010-11-21 19:28:32 +01:00
dialog_copper_zones.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_copper_zones_base.cpp Add priority level to zones. 2012-01-29 20:29:19 +01:00
dialog_copper_zones_base.fbp Add priority level to zones. 2012-01-29 20:29:19 +01:00
dialog_copper_zones_base.h Add priority level to zones. 2012-01-29 20:29:19 +01:00
dialog_design_rules.cpp Removal of internal units. 2012-04-16 19:31:29 -04:00
dialog_design_rules.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_design_rules_aux_helper_class.h Pcbnew: files housekeeping and code cleanup 2010-11-26 21:00:39 +01:00
dialog_design_rules_base.cpp Layers manager: add in popup menu option to hide all coppers layers but active layer. 2012-02-17 20:43:43 +01:00
dialog_design_rules_base.fbp Layers manager: add in popup menu option to hide all coppers layers but active layer. 2012-02-17 20:43:43 +01:00
dialog_design_rules_base.h Layers manager: add in popup menu option to hide all coppers layers but active layer. 2012-02-17 20:43:43 +01:00
dialog_dimension_editor_base.cpp Eeschema: fix crash in intermediate netlist generation when a component has no pins (like logos or images). 2011-11-24 20:57:41 +01:00
dialog_dimension_editor_base.fbp Eeschema: fix crash in intermediate netlist generation when a component has no pins (like logos or images). 2011-11-24 20:57:41 +01:00
dialog_dimension_editor_base.h Eeschema: fix crash in intermediate netlist generation when a component has no pins (like logos or images). 2011-11-24 20:57:41 +01:00
dialog_display_options.cpp switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_display_options.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_display_options_base.cpp pcbnew: 2011-09-30 12:24:10 +04:00
dialog_display_options_base.fbp Commit patch fixing an issue in pan with middle mouse button (from lajos kamocsay) 2012-04-15 12:33:35 +02:00
dialog_display_options_base.h pcbnew: 2011-09-30 12:24:10 +04:00
dialog_drc.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_drc.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_drc_base.cpp Pcbnew: code cleanup 2010-11-26 18:47:35 +01:00
dialog_drc_base.fbp Pcbnew: code cleanup 2010-11-26 18:47:35 +01:00
dialog_drc_base.h Pcbnew: code cleanup 2010-11-26 18:47:35 +01:00
dialog_edit_module_for_BoardEditor.cpp LEGACY_PLUGIN is now in full use: 2012-04-16 22:12:53 -05:00
dialog_edit_module_for_BoardEditor.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_edit_module_for_BoardEditor_base.cpp Add module and pad local parameters for pad-zone connections (thermal, solid etc.) in pcbnew. 2012-02-25 01:23:46 +02:00
dialog_edit_module_for_BoardEditor_base.fbp Add module and pad local parameters for pad-zone connections (thermal, solid etc.) in pcbnew. 2012-02-25 01:23:46 +02:00
dialog_edit_module_for_BoardEditor_base.h Add module and pad local parameters for pad-zone connections (thermal, solid etc.) in pcbnew. 2012-02-25 01:23:46 +02:00
dialog_edit_module_for_Modedit.cpp LEGACY_PLUGIN is now in full use: 2012-04-16 22:12:53 -05:00
dialog_edit_module_for_Modedit.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_edit_module_for_Modedit_base.cpp Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_edit_module_for_Modedit_base.fbp Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_edit_module_for_Modedit_base.h Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_edit_module_text.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_edit_module_text_base.cpp Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_edit_module_text_base.fbp Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_edit_module_text_base.h Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_exchange_modules_base.cpp Dialog design rules cosmetic enhancement 2011-04-16 17:03:21 +02:00
dialog_exchange_modules_base.fbp Dialog design rules cosmetic enhancement 2011-04-16 17:03:21 +02:00
dialog_exchange_modules_base.h Dialog design rules cosmetic enhancement 2011-04-16 17:03:21 +02:00
dialog_export_3Dfiles_base.cpp Pcbnew: files housekeeping. 2010-11-24 21:37:00 +01:00
dialog_export_3Dfiles_base.fbp Pcbnew: files housekeeping. 2010-11-24 21:37:00 +01:00
dialog_export_3Dfiles_base.h Pcbnew: files housekeeping. 2010-11-24 21:37:00 +01:00
dialog_freeroute_exchange.cpp switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_freeroute_exchange.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_freeroute_exchange_base.cpp minor cleanup. minor enhancements. Finish file housekeeping. add Bug 682586 fix from Mark van Doesburg. 2010-11-29 16:05:01 +01:00
dialog_freeroute_exchange_base.fbp minor cleanup. minor enhancements. Finish file housekeeping. add Bug 682586 fix from Mark van Doesburg. 2010-11-29 16:05:01 +01:00
dialog_freeroute_exchange_base.h minor cleanup. minor enhancements. Finish file housekeeping. add Bug 682586 fix from Mark van Doesburg. 2010-11-29 16:05:01 +01:00
dialog_freeroute_exchange_help.html minor cleanup. minor enhancements. Finish file housekeeping. add Bug 682586 fix from Mark van Doesburg. 2010-11-29 16:05:01 +01:00
dialog_gen_module_position_file_base.cpp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_gen_module_position_file_base.fbp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_gen_module_position_file_base.h Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_gendrill.cpp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_gendrill.h Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_gendrill_base.cpp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_gendrill_base.fbp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_gendrill_base.h Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_general_options.cpp All: new middle mouse pan feature, from lajos kamocsay (and jp charras for some enhancements). 2012-04-11 20:54:20 +02:00
dialog_general_options.h All: new middle mouse pan feature, from lajos kamocsay (and jp charras for some enhancements). 2012-04-11 20:54:20 +02:00
dialog_general_options_BoardEditor_base.cpp Commit patch fixing an issue in pan with middle mouse button (from lajos kamocsay) 2012-04-15 12:33:35 +02:00
dialog_general_options_BoardEditor_base.fbp Fix a serious bug in EDA_RECT::Intersects 2012-04-16 14:56:01 +02:00
dialog_general_options_BoardEditor_base.h All: new middle mouse pan feature, from lajos kamocsay (and jp charras for some enhancements). 2012-04-11 20:54:20 +02:00
dialog_global_deletion.cpp Undo redo change and code cleanup. 2012-02-05 14:02:46 +01:00
dialog_global_deletion.h * Switch to C++'s true and false and away from C" TRUE and FALSE. 2012-01-22 23:17:34 -06:00
dialog_global_deletion_base.cpp Eeschema: fix bug #919636 2012-01-21 16:02:49 +01:00
dialog_global_deletion_base.fbp Eeschema: fix bug #919636 2012-01-21 16:02:49 +01:00
dialog_global_deletion_base.h Eeschema: fix bug #919636 2012-01-21 16:02:49 +01:00
dialog_global_edit_tracks_and_vias.cpp More internal unit improvements. 2012-04-13 14:51:24 -04:00
dialog_global_edit_tracks_and_vias.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_global_edit_tracks_and_vias_base.cpp Pcbnew: code cleanup 2010-11-26 18:47:35 +01:00
dialog_global_edit_tracks_and_vias_base.fbp Pcbnew: code cleanup 2010-11-26 18:47:35 +01:00
dialog_global_edit_tracks_and_vias_base.h Pcbnew: code cleanup 2010-11-26 18:47:35 +01:00
dialog_global_pads_edition_base.cpp Pcbnew: Fix error message in Module Editor after a global pad change. 2011-12-30 13:29:54 +01:00
dialog_global_pads_edition_base.fbp Pcbnew: Fix error message in Module Editor after a global pad change. 2011-12-30 13:29:54 +01:00
dialog_global_pads_edition_base.h Pcbnew: Fix error message in Module Editor after a global pad change. 2011-12-30 13:29:54 +01:00
dialog_graphic_item_properties.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_graphic_item_properties_base.cpp Modedit: add dialog to edit footprint body items. Fix also minor issues about footprint body items edition. 2012-02-12 20:39:37 +01:00
dialog_graphic_item_properties_base.fbp Dialog exit: better icon. 2012-03-09 19:58:58 +01:00
dialog_graphic_item_properties_base.h Modedit: add dialog to edit footprint body items. Fix also minor issues about footprint body items edition. 2012-02-12 20:39:37 +01:00
dialog_graphic_item_properties_for_Modedit.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_graphic_items_options.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_graphic_items_options.h Modedit: add dialog to edit footprint body items. Fix also minor issues about footprint body items edition. 2012-02-12 20:39:37 +01:00
dialog_graphic_items_options_base.cpp Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_graphic_items_options_base.fbp Dialog exit: better icon. 2012-03-09 19:58:58 +01:00
dialog_graphic_items_options_base.h Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_layers_setup.cpp merge 2012-02-06 01:14:51 -06:00
dialog_layers_setup_base.cpp Pcbnew: files housekeeping and code cleanup 2010-11-26 21:00:39 +01:00
dialog_layers_setup_base.fbp Pcbnew: files housekeeping and code cleanup 2010-11-26 21:00:39 +01:00
dialog_layers_setup_base.h Pcbnew: files housekeeping and code cleanup 2010-11-26 21:00:39 +01:00
dialog_mask_clearance.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_mask_clearance.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_mask_clearance_base.cpp Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_mask_clearance_base.fbp Fix a serious bug in EDA_RECT::Intersects 2012-04-16 14:56:01 +02:00
dialog_mask_clearance_base.h Fix very minor bugs. Boost update. Pcbnew: files housekeeping and code cleanup. 2010-11-26 12:55:34 +01:00
dialog_netlist.cpp All: added a standard exit dialog called by int DisplayExitDialog( wxWindow* aParent, const wxString& aMessage ) 2012-03-08 18:47:23 +01:00
dialog_netlist.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_netlist_fbp.cpp Dialog escape key termination and default button fixes. 2011-03-14 15:17:42 -04:00
dialog_netlist_fbp.fbp Dialog escape key termination and default button fixes. 2011-03-14 15:17:42 -04:00
dialog_netlist_fbp.h Dialog escape key termination and default button fixes. 2011-03-14 15:17:42 -04:00
dialog_non_copper_zones_properties_base.cpp Pcbnew: files housekeeping. 2010-11-24 21:37:00 +01:00
dialog_non_copper_zones_properties_base.fbp Pcbnew: files housekeeping. 2010-11-24 21:37:00 +01:00
dialog_non_copper_zones_properties_base.h Pcbnew: files housekeeping. 2010-11-24 21:37:00 +01:00
dialog_orient_footprints.cpp // Dick Hollenbeck's KiROUND R&D 2012-04-19 01:55:45 -05:00
dialog_orient_footprints_base.cpp Pcbnew: code cleanup 2010-11-26 18:47:35 +01:00
dialog_orient_footprints_base.fbp Pcbnew: code cleanup 2010-11-26 18:47:35 +01:00
dialog_orient_footprints_base.h Pcbnew: code cleanup 2010-11-26 18:47:35 +01:00
dialog_pad_properties.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_pad_properties_base.cpp Backout my usage of DIALOG_EXTEND_WITH_SHIM in favor of wxFormbuilder's 2012-03-22 13:36:20 -05:00
dialog_pad_properties_base.fbp Backout my usage of DIALOG_EXTEND_WITH_SHIM in favor of wxFormbuilder's 2012-03-22 13:36:20 -05:00
dialog_pad_properties_base.h Backout my usage of DIALOG_EXTEND_WITH_SHIM in favor of wxFormbuilder's 2012-03-22 13:36:20 -05:00
dialog_pcb_text_properties.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_pcb_text_properties_base.cpp Backout my usage of DIALOG_EXTEND_WITH_SHIM in favor of wxFormbuilder's 2012-03-22 13:36:20 -05:00
dialog_pcb_text_properties_base.fbp Backout my usage of DIALOG_EXTEND_WITH_SHIM in favor of wxFormbuilder's 2012-03-22 13:36:20 -05:00
dialog_pcb_text_properties_base.h Backout my usage of DIALOG_EXTEND_WITH_SHIM in favor of wxFormbuilder's 2012-03-22 13:36:20 -05:00
dialog_pcbnew_config_libs_and_paths.cpp All: added a standard exit dialog called by int DisplayExitDialog( wxWindow* aParent, const wxString& aMessage ) 2012-03-08 18:47:23 +01:00
dialog_pcbnew_config_libs_and_paths.h switch to <> for includes from "" per conversation with Jean-Pierre and Wayne, adjust search paths 2012-01-22 22:33:36 -06:00
dialog_pcbnew_config_libs_and_paths_fbp.cpp Minor dialog fixes and code cleaning. 2011-10-17 16:01:27 -04:00
dialog_pcbnew_config_libs_and_paths_fbp.fbp Minor dialog fixes and code cleaning. 2011-10-17 16:01:27 -04:00
dialog_pcbnew_config_libs_and_paths_fbp.h Minor dialog fixes and code cleaning. 2011-10-17 16:01:27 -04:00
dialog_plot_base.cpp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_plot_base.fbp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_plot_base.h Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_print_for_modedit.cpp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_print_for_modedit_base.cpp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_print_for_modedit_base.fbp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_print_for_modedit_base.h Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_print_using_printer.cpp More internal unit improvements. 2012-04-16 13:39:32 -04:00
dialog_print_using_printer_base.cpp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_print_using_printer_base.fbp Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_print_using_printer_base.h Remove g_PcbPlotOptions, use wxformbuilder to subclass DIALOG_SHIM on several dialogs 2012-04-05 13:27:56 -05:00
dialog_set_grid.fbp pcbnew: 2011-09-09 15:02:03 +04:00
dialog_set_grid_base.cpp pcbnew: 2011-09-09 15:02:03 +04:00
dialog_set_grid_base.h pcbnew: 2011-09-09 15:02:03 +04:00