Quantcast

Results are not as expected

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Results are not as expected

Claudio Alexandre
Please, can anyone explain this situation?
In some situations the results of subtractions are not as expected when we extract the integer part of the number.
Another question is about my failure to get the correct month of the current date.
Here is the code used to test and the results obtained.
+!start
   : true
 <- N0=0.9; N1=1.9; N2=2.9; N3=3.9; N4=4.9; N5=5.9;
     N6=6.9; N7=7.9; N8=8.9; N9=9.9; N10=10.9;
     N11=11.9;   N12=12.9;   N13=13.9;   N14=14.9;
     R0=N0-0; R1=N1-1; R2=N2-2; R3=N3-3; R4=N4-4; R5=N5-5;
     R6=N6-6; R7=N7-7; R8=N8-8; R9=N9-9; R10=N10-10;
     R11=N11-11; R12=N12-12; R13=N13-13; R14=N14-14;
     .print("N0=",N0,"  N1=",N1,"  N2=",N2,"  N3=",N3,"  N4=",N4,"  N5=",N5);
     .print("N6=",N6,"  N7=",N7,"  N8=",N8,"  N9=",N9,"  N10=",N10);
     .print("N11=",N11,"  N12=",N12,"  N13=",N13,"  N14=",N14);
     .print(N0," - 0 = ",R0); .print(N1," - 1 = ",R1);
     .print(N2," - 2 = ",R2); .print(N3," - 3 = ",R3);
     .print(N4," - 4 = ",R4); .print(N5," - 5 = ",R5);
     .print(N6," - 6 = ",R6); .print(N7," - 7 = ",R7);
     .print(N8," - 8 = ",R8); .print(N9," - 9 = ",R9);
     .print(N10," - 10 = ",R10); .print(N11," - 11 = ",R11);
     .print(N12," - 12 = ",R12); .print(N13," - 13 = ",R13);
     .print(N14," - 14 = ",R14);
     .date(AA, MM, DD); .print("Today ",DD,"-",MM,"-",AA).
---------------------------
CArtAgO Http Server running on http://NN:3273
Jason Http Server running on http://NN:3272
[test] N0=0.9  N1=1.9  N2=2.9  N3=3.9  N4=4.9  N5=5.9
[test] N6=6.9  N7=7.9  N8=8.9  N9=9.9  N10=10.9
[test] N11=11.9  N12=12.9  N13=13.9  N14=14.9
[test] 0.9 - 0 = 0.9
[test] 1.9 - 1 = 0.8999999999999999
[test] 2.9 - 2 = 0.8999999999999999
[test] 3.9 - 3 = 0.8999999999999999
[test] 4.9 - 4 = 0.9000000000000004
[test] 5.9 - 5 = 0.9000000000000004
[test] 6.9 - 6 = 0.9000000000000004
[test] 7.9 - 7 = 0.9000000000000004
[test] 8.9 - 8 = 0.9000000000000004
[test] 9.9 - 9 = 0.9000000000000004
[test] 10.9 - 10 = 0.9000000000000004
[test] 11.9 - 11 = 0.9000000000000004
[test] 12.9 - 12 = 0.9000000000000004
[test] 13.9 - 13 = 0.9000000000000004
[test] 14.9 - 14 = 0.9000000000000004
[test] Today 23-2-2017
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Results are not as expected

Jomi Hubner
Hello Claudio,

the results in the arithmetic operations are “normal” when real numbers are considered in many programming languages. You may use math.round(.) if necessary.

there is a bug in .date internal action and the month starts by 0 instead of 1, so January is 0. It will be fixed in future releases. For now, just add 1 in MM.

HTH,

Jomi

--
Jomi Fred Hubner
Federal University of Santa Catarina
Department of Automation and Systems Engineering
PO Box 476, Florianópolis, SC
88040-900 Brazil
http://jomi.das.ufsc.br

> On 23 Mar 2017, at 17:08, Claudio Alexandre <[hidden email]> wrote:
>
> Please, can anyone explain this situation?
> In some situations the results of subtractions are not as expected when we
> extract the integer part of the number.
> Another question is about my failure to get the correct month of the current
> date.
> Here is the code used to test and the results obtained.
> +!start
>   : true
> <- N0=0.9; N1=1.9; N2=2.9; N3=3.9; N4=4.9; N5=5.9;
>     N6=6.9; N7=7.9; N8=8.9; N9=9.9; N10=10.9;
>     N11=11.9;   N12=12.9;   N13=13.9;   N14=14.9;
>     R0=N0-0; R1=N1-1; R2=N2-2; R3=N3-3; R4=N4-4; R5=N5-5;
>     R6=N6-6; R7=N7-7; R8=N8-8; R9=N9-9; R10=N10-10;
>     R11=N11-11; R12=N12-12; R13=N13-13; R14=N14-14;
>     .print("N0=",N0,"  N1=",N1,"  N2=",N2,"  N3=",N3,"  N4=",N4,"
> N5=",N5);
>     .print("N6=",N6,"  N7=",N7,"  N8=",N8,"  N9=",N9,"  N10=",N10);
>     .print("N11=",N11,"  N12=",N12,"  N13=",N13,"  N14=",N14);
>     .print(N0," - 0 = ",R0); .print(N1," - 1 = ",R1);
>     .print(N2," - 2 = ",R2); .print(N3," - 3 = ",R3);
>     .print(N4," - 4 = ",R4); .print(N5," - 5 = ",R5);
>     .print(N6," - 6 = ",R6); .print(N7," - 7 = ",R7);
>     .print(N8," - 8 = ",R8); .print(N9," - 9 = ",R9);
>     .print(N10," - 10 = ",R10); .print(N11," - 11 = ",R11);
>     .print(N12," - 12 = ",R12); .print(N13," - 13 = ",R13);
>     .print(N14," - 14 = ",R14);
>     .date(AA, MM, DD); .print("Today ",DD,"-",MM,"-",AA).
> ---------------------------
> CArtAgO Http Server running on http://NN:3273
> Jason Http Server running on http://NN:3272
> [test] N0=0.9  N1=1.9  N2=2.9  N3=3.9  N4=4.9  N5=5.9
> [test] N6=6.9  N7=7.9  N8=8.9  N9=9.9  N10=10.9
> [test] N11=11.9  N12=12.9  N13=13.9  N14=14.9
> [test] 0.9 - 0 = 0.9
> [test] 1.9 - 1 = 0.8999999999999999
> [test] 2.9 - 2 = 0.8999999999999999
> [test] 3.9 - 3 = 0.8999999999999999
> [test] 4.9 - 4 = 0.9000000000000004
> [test] 5.9 - 5 = 0.9000000000000004
> [test] 6.9 - 6 = 0.9000000000000004
> [test] 7.9 - 7 = 0.9000000000000004
> [test] 8.9 - 8 = 0.9000000000000004
> [test] 9.9 - 9 = 0.9000000000000004
> [test] 10.9 - 10 = 0.9000000000000004
> [test] 11.9 - 11 = 0.9000000000000004
> [test] 12.9 - 12 = 0.9000000000000004
> [test] 13.9 - 13 = 0.9000000000000004
> [test] 14.9 - 14 = 0.9000000000000004
> [test] Today 23-2-2017
>
>
>
> --
> View this message in context: http://jason.2324890.n4.nabble.com/Results-are-not-as-expected-tp846.html
> Sent from the jason-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Results are not as expected

Claudio Alexandre
Thanks.
Function implemented (truncate), about ".date" I was already adding 1 in month.
Loading...