PDA

View Full Version : string filter

fortress
12-14-2003, 10:12 PM
hello well i have made a lot of progress to my exporter

but cam acrossed somethign today i noticed the output for bone pos and rot gives some strange things

3.62684e-006 15.5859 -1.46328e-006

thats one output of a bones rotation values.

my question
is there a way to filter that or fiter the string i build up before i output it i want to take out all values past the e-

any suggestions or anyway to get the values with out that

also any idea why that happens
Thank you

fxnut
12-15-2003, 03:14 AM
From your post I was unable to figure out if you already know this but...

as an example, a value of "1.3 e-002" is the same as "0.013". Basically the exponent (the "e-002" part) means that you multiply the number in front of the "e" by 10 to the power of the number in the exponent. I.e.

1.3e-002 = 1.3 x (10^-2) = 1.3 / (10 x 10) = 0.013

So your number of "3.62684e-006" is actually 0.00000362684

If you're exporting to an application written in C or something similar, you'll be able to parse this string format automatically using a command called something like atof() or something similar. There should be no need to unmangle the exponential format when you export.

faulknermano
12-15-2003, 07:39 AM
you can round it off using round().

fortress
12-15-2003, 11:10 AM

for my purpose rounding will work but thanks for the details on the exponent

fortress
12-15-2003, 09:49 PM
well using round() helped so far but it will remove the decimal point at times os i get just 0 instead of 0.0
i dont think this will be a problem but it may we shall see soon enough.

another question i had was how do i get a normal for a given point ?

Blochi
01-11-2004, 04:18 AM
dunno if you still care,
But check the Reference page 13 for the round command. It accepts a second parameter that lets you set the decimal position where to round....

-Blochi

fortress
01-11-2004, 02:11 PM
accually i do :)
i just revisited this problem last night i did a almost a complete re wright of the coe to clean it all up and optimize a bit

that will help a lot thanks for the tip

fortress
01-11-2004, 02:16 PM
wait thats what i have been doing
only problem is this

say i have a number like

0.5678e-005
and i use round like this

round(mynumber,4) it iwill return 0

Blochi
01-11-2004, 02:44 PM
that's because 0.000005678 is close to zero.

But I guess your actual problem is that 0 counts as interger, suddenly. You maybe could call it a = number(round(value));

Blochi

fortress
01-11-2004, 03:22 PM
im not sure how changing the way i call the round function would make any difference

i think im going to just reformat my data as i output it

i need 6 decimal places. even if it is all zero's
0.000000

fortress
01-11-2004, 05:39 PM
well i think im going to just leave the rounding and then pad it if i have to