diff --git a/BorMakefile b/BorMakefile index f90ff2f..5e31bc7 100644 --- a/BorMakefile +++ b/BorMakefile @@ -66,12 +66,14 @@ clean: del /f /q src\math\mmx.obj del /f /q src\math\nbsd_pow.obj del /f /q src\math\nbsd_endian.obj + del /f /q src\math\nbsd_copysign.obj + del /f /q src\math\nbsd_scalbn.obj del /f /q src\color_picker\color_picker.obj del /f /q src\backend\gdi.obj del /f /q src\Mw.dll -src\Mw.dll: src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\math\nbsd_pow.obj src\math\nbsd_endian.obj src\color_picker\color_picker.obj src\backend\gdi.obj - $(LD) $(LDFLAGS) -e$@ src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\math\nbsd_pow.obj src\math\nbsd_endian.obj src\color_picker\color_picker.obj src\backend\gdi.obj -lopengl32.lib -lgdi32.lib -luser32.lib +src\Mw.dll: src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\math\nbsd_pow.obj src\math\nbsd_endian.obj src\math\nbsd_copysign.obj src\math\nbsd_scalbn.obj src\color_picker\color_picker.obj src\backend\gdi.obj + $(LD) $(LDFLAGS) -e$@ src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\math\nbsd_pow.obj src\math\nbsd_endian.obj src\math\nbsd_copysign.obj src\math\nbsd_scalbn.obj src\color_picker\color_picker.obj src\backend\gdi.obj -lopengl32.lib -lgdi32.lib -luser32.lib implib src\Mw.lib src\Mw.dll .c.obj: diff --git a/NTMakefile b/NTMakefile index 9c9b0a2..df892a7 100644 --- a/NTMakefile +++ b/NTMakefile @@ -66,12 +66,14 @@ clean: del /f /q src\math\mmx.obj del /f /q src\math\nbsd_pow.obj del /f /q src\math\nbsd_endian.obj + del /f /q src\math\nbsd_copysign.obj + del /f /q src\math\nbsd_scalbn.obj del /f /q src\color_picker\color_picker.obj del /f /q src\backend\gdi.obj del /f /q src\Mw.dll -src\Mw.dll: src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\math\nbsd_pow.obj src\math\nbsd_endian.obj src\color_picker\color_picker.obj src\backend\gdi.obj - $(LD) $(LDFLAGS) /OUT:$@ src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\math\nbsd_pow.obj src\math\nbsd_endian.obj src\color_picker\color_picker.obj src\backend\gdi.obj opengl32.lib gdi32.lib user32.lib +src\Mw.dll: src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\math\nbsd_pow.obj src\math\nbsd_endian.obj src\math\nbsd_copysign.obj src\math\nbsd_scalbn.obj src\color_picker\color_picker.obj src\backend\gdi.obj + $(LD) $(LDFLAGS) /OUT:$@ src\core.obj src\text.obj src\string.obj src\draw.obj src\default.obj src\filechooser.obj src\lowlevel.obj src\error.obj src\unicode.obj src\color.obj src\directory.obj src\messagebox.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\icon\info.obj src\icon\note.obj src\icon\warning.obj src\icon\error.obj src\icon\news.obj src\icon\directory.obj src\icon\file.obj src\icon\back.obj src\icon\forward.obj src\icon\up.obj src\icon\computer.obj src\icon\search.obj src\icon\down.obj src\icon\left.obj src\icon\right.obj src\cursor\default.obj src\cursor\cross.obj src\cursor\text.obj src\cursor\hidden.obj src\widget\button.obj src\widget\frame.obj src\widget\opengl.obj src\widget\window.obj src\widget\menu.obj src\widget\entry.obj src\widget\submenu.obj src\widget\viewport.obj src\widget\image.obj src\widget\scrollbar.obj src\widget\checkbox.obj src\widget\label.obj src\widget\listbox.obj src\widget\numberentry.obj src\widget\progressbar.obj src\widget\radiobox.obj src\font\boldttf.obj src\font\ttf.obj src\font\boldfont.obj src\font\font.obj src\math\default.obj src\math\math.obj src\math\mmx.obj src\math\nbsd_pow.obj src\math\nbsd_endian.obj src\math\nbsd_copysign.obj src\math\nbsd_scalbn.obj src\color_picker\color_picker.obj src\backend\gdi.obj opengl32.lib gdi32.lib user32.lib .c.obj: diff --git a/WatMakefile b/WatMakefile index 79704f1..d02e9a7 100644 --- a/WatMakefile +++ b/WatMakefile @@ -65,12 +65,14 @@ clean: .SYMBOLIC %erase src/math/mmx.obj %erase src/math/nbsd_pow.obj %erase src/math/nbsd_endian.obj + %erase src/math/nbsd_copysign.obj + %erase src/math/nbsd_scalbn.obj %erase src/color_picker/color_picker.obj %erase src/backend/gdi.obj %erase src/Mw.dll -src/Mw.dll: src/core.obj src/text.obj src/string.obj src/draw.obj src/default.obj src/filechooser.obj src/lowlevel.obj src/error.obj src/unicode.obj src/color.obj src/directory.obj src/messagebox.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/icon/info.obj src/icon/note.obj src/icon/warning.obj src/icon/error.obj src/icon/news.obj src/icon/directory.obj src/icon/file.obj src/icon/back.obj src/icon/forward.obj src/icon/up.obj src/icon/computer.obj src/icon/search.obj src/icon/down.obj src/icon/left.obj src/icon/right.obj src/cursor/default.obj src/cursor/cross.obj src/cursor/text.obj src/cursor/hidden.obj src/widget/button.obj src/widget/frame.obj src/widget/opengl.obj src/widget/window.obj src/widget/menu.obj src/widget/entry.obj src/widget/submenu.obj src/widget/viewport.obj src/widget/image.obj src/widget/scrollbar.obj src/widget/checkbox.obj src/widget/label.obj src/widget/listbox.obj src/widget/numberentry.obj src/widget/progressbar.obj src/widget/radiobox.obj src/font/boldttf.obj src/font/ttf.obj src/font/boldfont.obj src/font/font.obj src/math/default.obj src/math/math.obj src/math/mmx.obj src/math/nbsd_pow.obj src/math/nbsd_endian.obj src/color_picker/color_picker.obj src/backend/gdi.obj - $(LD) $(LDFLAGS) option implib=src/Mw.lib name $@ file src/core.obj file src/text.obj file src/string.obj file src/draw.obj file src/default.obj file src/filechooser.obj file src/lowlevel.obj file src/error.obj file src/unicode.obj file src/color.obj file src/directory.obj file src/messagebox.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/icon/info.obj file src/icon/note.obj file src/icon/warning.obj file src/icon/error.obj file src/icon/news.obj file src/icon/directory.obj file src/icon/file.obj file src/icon/back.obj file src/icon/forward.obj file src/icon/up.obj file src/icon/computer.obj file src/icon/search.obj file src/icon/down.obj file src/icon/left.obj file src/icon/right.obj file src/cursor/default.obj file src/cursor/cross.obj file src/cursor/text.obj file src/cursor/hidden.obj file src/widget/button.obj file src/widget/frame.obj file src/widget/opengl.obj file src/widget/window.obj file src/widget/menu.obj file src/widget/entry.obj file src/widget/submenu.obj file src/widget/viewport.obj file src/widget/image.obj file src/widget/scrollbar.obj file src/widget/checkbox.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/numberentry.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/font/boldttf.obj file src/font/ttf.obj file src/font/boldfont.obj file src/font/font.obj file src/math/default.obj file src/math/math.obj file src/math/mmx.obj file src/math/nbsd_pow.obj file src/math/nbsd_endian.obj file src/color_picker/color_picker.obj file src/backend/gdi.obj library clib3r.lib library opengl32.lib library gdi32.lib library user32.lib +src/Mw.dll: src/core.obj src/text.obj src/string.obj src/draw.obj src/default.obj src/filechooser.obj src/lowlevel.obj src/error.obj src/unicode.obj src/color.obj src/directory.obj src/messagebox.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/icon/info.obj src/icon/note.obj src/icon/warning.obj src/icon/error.obj src/icon/news.obj src/icon/directory.obj src/icon/file.obj src/icon/back.obj src/icon/forward.obj src/icon/up.obj src/icon/computer.obj src/icon/search.obj src/icon/down.obj src/icon/left.obj src/icon/right.obj src/cursor/default.obj src/cursor/cross.obj src/cursor/text.obj src/cursor/hidden.obj src/widget/button.obj src/widget/frame.obj src/widget/opengl.obj src/widget/window.obj src/widget/menu.obj src/widget/entry.obj src/widget/submenu.obj src/widget/viewport.obj src/widget/image.obj src/widget/scrollbar.obj src/widget/checkbox.obj src/widget/label.obj src/widget/listbox.obj src/widget/numberentry.obj src/widget/progressbar.obj src/widget/radiobox.obj src/font/boldttf.obj src/font/ttf.obj src/font/boldfont.obj src/font/font.obj src/math/default.obj src/math/math.obj src/math/mmx.obj src/math/nbsd_pow.obj src/math/nbsd_endian.obj src/math/nbsd_copysign.obj src/math/nbsd_scalbn.obj src/color_picker/color_picker.obj src/backend/gdi.obj + $(LD) $(LDFLAGS) option implib=src/Mw.lib name $@ file src/core.obj file src/text.obj file src/string.obj file src/draw.obj file src/default.obj file src/filechooser.obj file src/lowlevel.obj file src/error.obj file src/unicode.obj file src/color.obj file src/directory.obj file src/messagebox.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/icon/info.obj file src/icon/note.obj file src/icon/warning.obj file src/icon/error.obj file src/icon/news.obj file src/icon/directory.obj file src/icon/file.obj file src/icon/back.obj file src/icon/forward.obj file src/icon/up.obj file src/icon/computer.obj file src/icon/search.obj file src/icon/down.obj file src/icon/left.obj file src/icon/right.obj file src/cursor/default.obj file src/cursor/cross.obj file src/cursor/text.obj file src/cursor/hidden.obj file src/widget/button.obj file src/widget/frame.obj file src/widget/opengl.obj file src/widget/window.obj file src/widget/menu.obj file src/widget/entry.obj file src/widget/submenu.obj file src/widget/viewport.obj file src/widget/image.obj file src/widget/scrollbar.obj file src/widget/checkbox.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/numberentry.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/font/boldttf.obj file src/font/ttf.obj file src/font/boldfont.obj file src/font/font.obj file src/math/default.obj file src/math/math.obj file src/math/mmx.obj file src/math/nbsd_pow.obj file src/math/nbsd_endian.obj file src/math/nbsd_copysign.obj file src/math/nbsd_scalbn.obj file src/color_picker/color_picker.obj file src/backend/gdi.obj library clib3r.lib library opengl32.lib library gdi32.lib library user32.lib @@ -192,6 +194,10 @@ src/math/nbsd_pow.obj: src/math/nbsd_pow.c $(CC) $(CFLAGS) -fo=$@ $< src/math/nbsd_endian.obj: src/math/nbsd_endian.c $(CC) $(CFLAGS) -fo=$@ $< +src/math/nbsd_copysign.obj: src/math/nbsd_copysign.c + $(CC) $(CFLAGS) -fo=$@ $< +src/math/nbsd_scalbn.obj: src/math/nbsd_scalbn.c + $(CC) $(CFLAGS) -fo=$@ $< src/color_picker/color_picker.obj: src/color_picker/color_picker.c $(CC) $(CFLAGS) -fo=$@ $< src/backend/gdi.obj: src/backend/gdi.c diff --git a/include/Mw/LowLevelMath.h b/include/Mw/LowLevelMath.h index c847558..9dbdb85 100644 --- a/include/Mw/LowLevelMath.h +++ b/include/Mw/LowLevelMath.h @@ -16,7 +16,7 @@ #endif #if !defined(MwLLMathMMX) -//#warning LowLevelMath.h does not yet support this platform +// #warning LowLevelMath.h does not yet support this platform #endif /*! diff --git a/mk/math.mk b/mk/math.mk index 2897c99..555cd35 100644 --- a/mk/math.mk +++ b/mk/math.mk @@ -1,3 +1,3 @@ # $Id$ L_OBJS += src/math/default.o src/math/math.o src/math/mmx.o -L_OBJS += src/math/nbsd_pow.o src/math/nbsd_endian.o +L_OBJS += src/math/nbsd_endian.o src/math/nbsd_pow.o src/math/nbsd_scalbn.o src/math/nbsd_copysign.o diff --git a/src/math/default.c b/src/math/default.c index 2efc504..d40b1c5 100644 --- a/src/math/default.c +++ b/src/math/default.c @@ -173,8 +173,7 @@ static MwLLMathVTable table_u16 = { default_shiftLeft_u16, default_equal_u16, default_greaterThen_u16, - NULL -}; + NULL}; static void default_add_u32(MwLLVec* a, MwLLVec* b, MwLLVec* out) { out->un.u32.a = a->un.u32.a + b->un.u32.a; @@ -225,8 +224,7 @@ static MwLLMathVTable table_u32 = { default_shiftLeft_u32, default_equal_u32, default_greaterThen_u32, - NULL -}; + NULL}; static void default_add_i8(MwLLVec* a, MwLLVec* b, MwLLVec* out) { out->un.i8.a = a->un.i8.a + b->un.i8.a; @@ -311,8 +309,7 @@ static MwLLMathVTable table_i8 = { default_shiftLeft_u8, default_equal_i8, default_greaterThen_i8, - NULL -}; + NULL}; static void default_add_i16(MwLLVec* a, MwLLVec* b, MwLLVec* out) { out->un.i16.a = a->un.i16.a + b->un.i16.a; out->un.i16.b = a->un.i16.b + b->un.i16.b; @@ -368,8 +365,7 @@ static MwLLMathVTable table_i16 = { default_shiftLeft_u16, default_equal_i16, default_greaterThen_i16, - NULL -}; + NULL}; static void default_add_i32(MwLLVec* a, MwLLVec* b, MwLLVec* out) { out->un.i32.a = a->un.i32.a + b->un.i32.a; @@ -412,8 +408,7 @@ static MwLLMathVTable table_i32 = { default_shiftLeft_u32, default_equal_i32, default_greaterThen_i32, - NULL -}; + NULL}; static MwLLMathVTable* defaultMultiTable[_MwLLVecType_Max] = { &table_u8, // _MwLLVecTypeU8x8 diff --git a/src/math/nbsd_copysign.c b/src/math/nbsd_copysign.c new file mode 100644 index 0000000..fb2dcba --- /dev/null +++ b/src/math/nbsd_copysign.c @@ -0,0 +1,31 @@ +/* @(#)s_copysign.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* $Id$ */ + +#include +#include "math_internal.h" + +/* + * copysign(double x, double y) + * copysign(x,y) returns a value with the magnitude of x and + * with the sign bit of y. + */ + +double +nbsd_copysign(double x, double y) { + MwU32 hx, hy; + GET_HIGH_WORD(hx, x); + GET_HIGH_WORD(hy, y); + SET_HIGH_WORD(x, (hx & 0x7fffffff) | (hy & 0x80000000)); + return x; +} diff --git a/src/math/nbsd_endian.c b/src/math/nbsd_endian.c index 83ff4a6..a1e308f 100644 --- a/src/math/nbsd_endian.c +++ b/src/math/nbsd_endian.c @@ -1,5 +1,6 @@ /* $Id$ */ -#include "nbsd_math.h" +#include +#include "math_internal.h" static char endian = 0; diff --git a/src/math/nbsd_math.h b/src/math/nbsd_math.h index c4871c1..ca22819 100644 --- a/src/math/nbsd_math.h +++ b/src/math/nbsd_math.h @@ -95,6 +95,9 @@ typedef union _ieee_double_shape_type { } while(0) double nbsd_pow(double a, double b); +double nbsd_scalbn(double x, int n); +double nbsd_scalbln(double x, long n); +double nbsd_copysign(double x, double y); char nbsd_endian(void); #endif diff --git a/src/math/nbsd_pow.c b/src/math/nbsd_pow.c index cc8778c..9821e18 100644 --- a/src/math/nbsd_pow.c +++ b/src/math/nbsd_pow.c @@ -133,7 +133,7 @@ nbsd_pow(double x, double y) { k = (iy >> 20) - 0x3ff; /* exponent */ if(k > 20) { j = ly >> (52 - k); - if((uint32_t)(j << (52 - k)) == ly) yisint = 2 - (j & 1); + if((MwU32)(j << (52 - k)) == ly) yisint = 2 - (j & 1); } else if(ly == 0) { j = iy >> (20 - k); if((j << (20 - k)) == iy) yisint = 2 - (j & 1); @@ -314,7 +314,7 @@ nbsd_pow(double x, double y) { z = one - (r - z); GET_HIGH_WORD(j, z); j += (n << 20); - if((j >> 20) <= 0) z = scalbn(z, n); /* subnormal output */ + if((j >> 20) <= 0) z = nbsd_scalbn(z, n); /* subnormal output */ else SET_HIGH_WORD(z, j); return s * z; diff --git a/src/math/nbsd_scalbn.c b/src/math/nbsd_scalbn.c new file mode 100644 index 0000000..73d67d7 --- /dev/null +++ b/src/math/nbsd_scalbn.c @@ -0,0 +1,65 @@ +/* @(#)s_scalbn.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* $Id$ */ + +#include +#include "math_internal.h" + +/* + * scalbn (double x, int n) + * scalbn(x,n) returns x* 2**n computed by exponent + * manipulation rather than by actually performing an + * exponentiation or a multiplication. + */ + +static const double + two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ + twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ + hugev = 1.0e+300, + tinyv = 1.0e-300; + +double +nbsd_scalbn(double x, int n) { + return nbsd_scalbln(x, n); +} + +double +nbsd_scalbln(double x, long n) { + MwI32 k, hx, lx; + EXTRACT_WORDS(hx, lx, x); + k = ((MwU32)hx & 0x7ff00000) >> 20; /* extract exponent */ + if(k == 0) { /* 0 or subnormal x */ + if((lx | (hx & 0x7fffffff)) == 0) return x; /* +-0 */ + x *= two54; + GET_HIGH_WORD(hx, x); + k = (((MwU32)hx & 0x7ff00000) >> 20) - 54; + if(n < -50000) return tinyv * x; /*underflow*/ + } + if(k == 0x7ff) return x + x; /* NaN or Inf */ + k = k + n; + if(k > 0x7fe) return hugev * nbsd_copysign(hugev, x); /* overflow */ + if(k > 0) /* normal result */ + { + SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20)); + return x; + } + if(k <= -54) { + if(n > 50000) /* in case integer overflow in n+k */ + return hugev * nbsd_copysign(hugev, x); /*overflow*/ + else + return tinyv * nbsd_copysign(tinyv, x); /*underflow*/ + } + k += 54; /* subnormal result */ + SET_HIGH_WORD(x, (hx & 0x800fffff) | (k << 20)); + return x * twom54; +}