Skip to content

Commit

Permalink
start coding double tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edadma committed Apr 3, 2018
1 parent 9260035 commit 4eb791b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 deletions.
43 changes: 43 additions & 0 deletions ftoa.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@


#include<stdio.h>
void flot(char* p, float x)
{
int n,i=0,k=0;
n=(int)x;
while(n>0)
{
x/=10;
n=(int)x;
i++;
}
*(p+i) = '.';
x *= 10;
n = (int)x;
x = x-n;
while(n>0)
{
if(k == i)
k++;
*(p+k)=48+n;
x *= 10;
n = (int)x;
x = x-n;
k++;
}
*(p+k) = '\0';
}

int main()
{
float x;
char a[20]={};
char* p=a;
printf("Enter the float value.");
scanf("%f",&x);
flot(p,x);
printf("The value=%s",p);
getchar();
return 0;
}

8 changes: 8 additions & 0 deletions src/test/scala/ExamplesNoCompressed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,12 @@ class ExamplesNoCompressed extends FreeSpec with PropertyChecks with Matchers {
""".trim.stripMargin
}

// "double" in {
// Run( "tests/double.hex" ) shouldBe
// """
// |true
// |true
// """.trim.stripMargin
// }

}
9 changes: 8 additions & 1 deletion tests/double.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,12 @@ printb( int b ) {

void
main() {
printb( 3.4 + 5.6 == 9.0 );
double a = 3.4;
double b = 5.6;
double c = 7.8;

printb( a + b == 9.0 );
// printb( 3.4 - 5.6 == -2.2 );
// printb( 3.4 * 5.6 == 19.04 );
// printb( 3.4 / 5.6 == 0.607142857 );
}
18 changes: 12 additions & 6 deletions tests/double.hex
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ Hex dump of section '.text':
0x00010160 03340100 13010101 67800000 130101fe .4......g.......
0x00010170 233c1100 23388100 13040102 93070500 #<..#8..........
0x00010180 2326f4fe 8327c4fe 9b870700 63880700 #&...'......c...
0x00010190 b7070100 9387071f 6f00c000 b7070100 ........o.......
0x000101a0 9387871f 13850700 eff09ff4 eff05ff9 .............._.
0x00010190 b7070100 93870723 6f00c000 b7070100 .......#o.......
0x000101a0 93878723 13850700 eff09ff4 eff05ff9 ...#.........._.
0x000101b0 13000000 83308101 03340101 13010102 .....0...4......
0x000101c0 67800000 130101ff 23341100 23308100 g.......#4..#0..
0x000101d0 13040101 13051000 eff05ff9 13000000 .........._.....
0x000101e0 83308100 03340100 13010101 67800000 .0...4......g...
0x000101c0 67800000 130101fe 233c1100 23388100 g.......#<..#8..
0x000101d0 13040102 b7070100 87b70724 2734f4fe ...........$'4..
0x000101e0 b7070100 87b78724 2730f4fe 073784fe .......$'0...7..
0x000101f0 873704fe 5377f702 b7070100 87b70725 .7..Sw.........%
0x00010200 d327f7a2 b337f000 93f7f70f 9b870700 .'...7..........
0x00010210 13850700 eff09ff5 13000000 83308101 .............0..
0x00010220 03340101 13010102 67800000 .4......g...


Hex dump of section '.rodata':
0x000101f0 74727565 00000000 66616c73 6500 true....false.
0x00010230 74727565 00000000 66616c73 65000000 true....false...
0x00010240 33333333 33330b40 66666666 66661640 333333.@ffffff.@
0x00010250 00000000 00002240 ......"@

0 comments on commit 4eb791b

Please sign in to comment.