discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

type casting.....

BB
Bruno Boettcher
Sun, Apr 12, 2020 9:40 AM

Hello!
i am rewriting a hinge lib, and to be sure to have a valid setup, i wanted
to check if the imputed value is uneven (??)
that's when i noted, there doesn't seem to be typecasting in openscad?

how do i achieve: x - 2*int(x/2) != 0 ?

i searched in the archives, but i only found on how to find out what type
is in the var, but not how to cast it....

thanks in advance!

ciao
Bruno

---==========
http://nohkumado.eu/, http://bboett.free.frhttp://aikido.nohkumado.eu/,
http://bboett.free.fr
http://aikido.zorn.free.fr

Hello! i am rewriting a hinge lib, and to be sure to have a valid setup, i wanted to check if the imputed value is uneven (??) that's when i noted, there doesn't seem to be typecasting in openscad? how do i achieve: x - 2*int(x/2) != 0 ? i searched in the archives, but i only found on how to find out what type is in the var, but not how to cast it.... thanks in advance! -- ciao Bruno =========================================== http://nohkumado.eu/, <http://bboett.free.fr>http://aikido.nohkumado.eu/, <http://bboett.free.fr> http://aikido.zorn.free.fr
NH
nop head
Sun, Apr 12, 2020 9:52 AM

There is no type casting because their is only one number type in OpenSCAD.
You could use floor(x/2) as that will be an integer value held in a
floating point type. The is also ceil() and round().

On Sun, 12 Apr 2020 at 10:41, Bruno Boettcher bboett@gmail.com wrote:

Hello!
i am rewriting a hinge lib, and to be sure to have a valid setup, i wanted
to check if the imputed value is uneven (??)
that's when i noted, there doesn't seem to be typecasting in openscad?

how do i achieve: x - 2*int(x/2) != 0 ?

i searched in the archives, but i only found on how to find out what type
is in the var, but not how to cast it....

thanks in advance!

ciao
Bruno

---==========
http://nohkumado.eu/, http://bboett.free.frhttp://aikido.nohkumado.eu/,
http://bboett.free.fr
http://aikido.zorn.free.fr


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

There is no type casting because their is only one number type in OpenSCAD. You could use floor(x/2) as that will be an integer value held in a floating point type. The is also ceil() and round(). On Sun, 12 Apr 2020 at 10:41, Bruno Boettcher <bboett@gmail.com> wrote: > Hello! > i am rewriting a hinge lib, and to be sure to have a valid setup, i wanted > to check if the imputed value is uneven (??) > that's when i noted, there doesn't seem to be typecasting in openscad? > > how do i achieve: x - 2*int(x/2) != 0 ? > > i searched in the archives, but i only found on how to find out what type > is in the var, but not how to cast it.... > > thanks in advance! > -- > ciao > Bruno > > =========================================== > http://nohkumado.eu/, <http://bboett.free.fr>http://aikido.nohkumado.eu/, > <http://bboett.free.fr> > http://aikido.zorn.free.fr > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Sun, Apr 12, 2020 9:53 AM

To test oddness x % 2 is useful.

On Sun, 12 Apr 2020 at 10:52, nop head nop.head@gmail.com wrote:

There is no type casting because their is only one number type in
OpenSCAD. You could use floor(x/2) as that will be an integer value held in
a floating point type. The is also ceil() and round().

On Sun, 12 Apr 2020 at 10:41, Bruno Boettcher bboett@gmail.com wrote:

Hello!
i am rewriting a hinge lib, and to be sure to have a valid setup, i
wanted to check if the imputed value is uneven (??)
that's when i noted, there doesn't seem to be typecasting in openscad?

how do i achieve: x - 2*int(x/2) != 0 ?

i searched in the archives, but i only found on how to find out what type
is in the var, but not how to cast it....

thanks in advance!

ciao
Bruno

---==========
http://nohkumado.eu/, http://bboett.free.frhttp://aikido.nohkumado.eu/,
http://bboett.free.fr
http://aikido.zorn.free.fr


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

To test oddness x % 2 is useful. On Sun, 12 Apr 2020 at 10:52, nop head <nop.head@gmail.com> wrote: > There is no type casting because their is only one number type in > OpenSCAD. You could use floor(x/2) as that will be an integer value held in > a floating point type. The is also ceil() and round(). > > On Sun, 12 Apr 2020 at 10:41, Bruno Boettcher <bboett@gmail.com> wrote: > >> Hello! >> i am rewriting a hinge lib, and to be sure to have a valid setup, i >> wanted to check if the imputed value is uneven (??) >> that's when i noted, there doesn't seem to be typecasting in openscad? >> >> how do i achieve: x - 2*int(x/2) != 0 ? >> >> i searched in the archives, but i only found on how to find out what type >> is in the var, but not how to cast it.... >> >> thanks in advance! >> -- >> ciao >> Bruno >> >> =========================================== >> http://nohkumado.eu/, <http://bboett.free.fr>http://aikido.nohkumado.eu/, >> <http://bboett.free.fr> >> http://aikido.zorn.free.fr >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >
BB
Bruno Boettcher
Sun, Apr 12, 2020 10:47 AM

ahh modulo! yes, nice one thanks!
that did it!

Am So., 12. Apr. 2020 um 11:54 Uhr schrieb nop head nop.head@gmail.com:

To test oddness x % 2 is useful.

On Sun, 12 Apr 2020 at 10:52, nop head nop.head@gmail.com wrote:

There is no type casting because their is only one number type in
OpenSCAD. You could use floor(x/2) as that will be an integer value held in
a floating point type. The is also ceil() and round().

On Sun, 12 Apr 2020 at 10:41, Bruno Boettcher bboett@gmail.com wrote:

Hello!
i am rewriting a hinge lib, and to be sure to have a valid setup, i
wanted to check if the imputed value is uneven (??)
that's when i noted, there doesn't seem to be typecasting in openscad?

how do i achieve: x - 2*int(x/2) != 0 ?

i searched in the archives, but i only found on how to find out what
type is in the var, but not how to cast it....

thanks in advance!

ciao
Bruno

---==========
http://nohkumado.eu/, http://bboett.free.frhttp://aikido.nohkumado.eu/,
http://bboett.free.fr
http://aikido.zorn.free.fr


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


ahh modulo! yes, nice one thanks! that did it! Am So., 12. Apr. 2020 um 11:54 Uhr schrieb nop head <nop.head@gmail.com>: > To test oddness x % 2 is useful. > > On Sun, 12 Apr 2020 at 10:52, nop head <nop.head@gmail.com> wrote: > >> There is no type casting because their is only one number type in >> OpenSCAD. You could use floor(x/2) as that will be an integer value held in >> a floating point type. The is also ceil() and round(). >> >> On Sun, 12 Apr 2020 at 10:41, Bruno Boettcher <bboett@gmail.com> wrote: >> >>> Hello! >>> i am rewriting a hinge lib, and to be sure to have a valid setup, i >>> wanted to check if the imputed value is uneven (??) >>> that's when i noted, there doesn't seem to be typecasting in openscad? >>> >>> how do i achieve: x - 2*int(x/2) != 0 ? >>> >>> i searched in the archives, but i only found on how to find out what >>> type is in the var, but not how to cast it.... >>> >>> thanks in advance! >>> -- >>> ciao >>> Bruno >>> >>> =========================================== >>> http://nohkumado.eu/, <http://bboett.free.fr>http://aikido.nohkumado.eu/, >>> <http://bboett.free.fr> >>> http://aikido.zorn.free.fr >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >> _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > -- ciao Bruno =========================================== http://nohkumado.eu/, <http://bboett.free.fr>http://aikido.nohkumado.eu/, <http://bboett.free.fr> http://aikido.zorn.free.fr