Skip to content

Commit

Permalink
g_float_flag is always true; drop it
Browse files Browse the repository at this point in the history
Fixes #243
  • Loading branch information
LegalizeAdulthood committed Feb 9, 2025
1 parent 17bc837 commit 2d3a338
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 68 deletions.
20 changes: 3 additions & 17 deletions libid/engine/calc_frac_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ void calc_frac_init() // initialize a *pile* of stuff for fractal calculation
|| g_debug_flag == DebugFlags::PREVENT_COORDINATE_GRID)
{
g_use_grid = false;
g_float_flag = true;
}
else
{
Expand Down Expand Up @@ -193,17 +192,9 @@ void calc_frac_init() // initialize a *pile* of stuff for fractal calculation
{
free_bf_vars();
}
g_float_flag = true;
if (g_user_std_calc_mode == 's')
if (g_user_std_calc_mode == 's' && g_fractal_type != FractalType::MANDEL)
{
if (g_fractal_type == FractalType::MANDEL)
{
g_float_flag = true;
}
else
{
g_user_std_calc_mode = '1';
}
g_user_std_calc_mode = '1';
}

// cppcheck-suppress variableScope
Expand Down Expand Up @@ -231,11 +222,6 @@ void calc_frac_init() // initialize a *pile* of stuff for fractal calculation
g_distance_estimator = 0; // can't do distest too
}

if (g_distance_estimator)
{
g_float_flag = true; // force floating point for dist est
}

assert(g_cur_fractal_specific == get_fractal_specific(g_fractal_type));
g_cur_fractal_specific = get_fractal_specific(g_fractal_type);

Expand Down Expand Up @@ -351,7 +337,7 @@ void calc_frac_init() // initialize a *pile* of stuff for fractal calculation
|| ratio_bad((double)g_l_y1[(g_logical_screen_x_dots >> 1)-1], ((double)g_l_y_min-g_l_y_3rd)/2))
{
expand_retry:
g_float_flag = true; // switch to floating pt
// switch to floating pt
if (g_calc_status == CalcStatus::RESUMABLE) // due to restore of an old file?
{
g_calc_status = CalcStatus::PARAMS_CHANGED; // whatever, it isn't resumable
Expand Down
27 changes: 5 additions & 22 deletions libid/engine/calcfrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2501,23 +2501,14 @@ int potential(double mag, long iterations)
}
else // pot = log(mag) / pow(2.0, (double)pot);
{
if (l_pot < 120 && !g_float_flag) // empirically determined limit of fShift
double d_tmp = std::log(mag) / (double) std::pow(2.0, (double) pot);
if (d_tmp > FLT_MIN) // prevent float type underflow
{
float f_mag = (float) mag;
f_log14(f_mag, f_tmp); // this SHOULD be non-negative
f_shift(f_tmp, (char)-l_pot, pot);
pot = (float) d_tmp;
}
else
{
double d_tmp = std::log(mag)/(double)std::pow(2.0, (double)pot);
if (d_tmp > FLT_MIN) // prevent float type underflow
{
pot = (float)d_tmp;
}
else
{
pot = 0.0F;
}
pot = 0.0F;
}
}

Expand All @@ -2528,15 +2519,7 @@ int potential(double mag, long iterations)
// potparam[2] -- rqlim value if changeable (bailout for modulus)
if (pot > 0.0)
{
if (g_float_flag)
{
pot = (float)std::sqrt((double)pot);
}
else
{
f_sqrt14(pot, f_tmp);
pot = f_tmp;
}
pot = (float) std::sqrt((double) pot);
pot = (float)(g_potential_params[0] - pot*g_potential_params[1] - 1.0);
}
else
Expand Down
1 change: 0 additions & 1 deletion libid/include/ui/cmdfiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ extern bool g_fast_restore;
extern int g_fill_color;
extern bool g_finite_attractor;
extern bool g_first_init;
extern bool g_float_flag;
extern std::string g_formula_filename;
extern std::string g_formula_name;
extern std::string g_gif_filename_mask;
Expand Down
2 changes: 1 addition & 1 deletion libid/io/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ static void setup_save_info(FractalInfo *save_info)
static_cast<char>(g_three_pass && g_std_calc_mode == '3' ? 127 : g_std_calc_mode);
save_info->dist_est_old =
static_cast<std::int16_t>(g_distance_estimator <= 32000 ? g_distance_estimator : 32000);
save_info->float_flag = static_cast<std::int16_t>(g_float_flag ? 1 : 0);
save_info->float_flag = static_cast<std::int16_t>(1);
save_info->bailout_old = static_cast<std::int16_t>(g_bailout >= 4 && g_bailout <= 32000 ? g_bailout : 0);
save_info->calc_time = static_cast<std::int32_t>(g_calc_time);
save_info->trig_index[0] = static_cast<Byte>(g_trig_index[0]);
Expand Down
4 changes: 0 additions & 4 deletions libid/io/loadfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,13 +1088,10 @@ int read_overlay() // read overlay/3D files, if reqr'd
else
{
Display3DMode const old_display_ed = g_display_3d;
bool const old_float_flag2 = g_float_flag;
g_display_3d = g_loaded_3d ? Display3DMode::YES : Display3DMode::NONE; // for <tab> display during next
g_float_flag = true; // ditto
int i = get_video_mode(&read_info, &blk_3_info);
driver_check_memory();
g_display_3d = old_display_ed;
g_float_flag = old_float_flag2;
if (i)
{
if (blk_2_info.got_data)
Expand Down Expand Up @@ -2263,7 +2260,6 @@ int file_get_window()
free_bf_vars();
}
g_bf_math = s_old_bf_math;
g_float_flag = true;

return c;
}
Expand Down
2 changes: 0 additions & 2 deletions libid/math/biginit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ static void init_bf2()
}
}

g_float_flag = true;

// Now split up the memory among the pointers
const auto alloc_size = [&ptr](int size)
{
Expand Down
1 change: 0 additions & 1 deletion libid/ui/cmdfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ bool g_potential_flag{}; // continuous potentia
bool g_potential_16bit{}; // store 16 bit continuous potential values
bool g_dither_flag{}; // true if we want to dither GIFs
bool g_ask_video{}; // flag for video prompting
bool g_float_flag{true}; //
int g_biomorph{}; // flag for biomorph
int g_user_biomorph_value{}; //
int g_show_file{}; // zero if file display pending
Expand Down
21 changes: 1 addition & 20 deletions libid/ui/tab_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,28 +339,9 @@ int tab_display() // display the status of the current image
// if (g_bf_math == bf_math_type::NONE)
++start_row;

int j = 0;
if (g_display_3d > Display3DMode::NONE)
{
j = 1;
}
else if (g_float_flag)
{
j = 1;
}

if (g_bf_math == BFMathType::NONE)
{
if (j)
{
driver_put_string(start_row, 45, C_GENERAL_HI, "Floating-point");
driver_put_string(-1, -1, C_GENERAL_HI,
(j == 1) ? " flag is activated" : " in use (required)");
}
else
{
driver_put_string(start_row, 45, C_GENERAL_HI, "Integer math is in use");
}
driver_put_string(start_row, 45, C_GENERAL_HI, "Floating-point in use");
}
else
{
Expand Down

0 comments on commit 2d3a338

Please sign in to comment.