You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2KB

  1. #include <inttypes.h>
  2. #include <stdio.h>
  3. #include <assert.h>
  4. #include "softfloat.h"
  5. #include "common.h"
  6. #include "log.h"
  7. #undef printf
  8. int main(){
  9. SoftFloat one= av_int2sf(1, 0);
  10. SoftFloat sf1, sf2;
  11. double d1, d2;
  12. int i, j;
  13. av_log_level = AV_LOG_DEBUG;
  14. d1= 1;
  15. for(i= 0; i<10; i++){
  16. d1= 1/(d1+1);
  17. }
  18. printf("test1 double=%d\n", (int)(d1 * (1<<24)));
  19. sf1= one;
  20. for(i= 0; i<10; i++){
  21. sf1= av_div_sf(one, av_normalize_sf(av_add_sf(one, sf1)));
  22. }
  23. printf("test1 sf =%d\n", av_sf2int(sf1, 24));
  24. for(i= 0; i<100; i++){
  25. START_TIMER
  26. d1= i;
  27. d2= i/100.0;
  28. for(j= 0; j<1000; j++){
  29. d1= (d1+1)*d2;
  30. }
  31. STOP_TIMER("float add mul")
  32. }
  33. printf("test2 double=%d\n", (int)(d1 * (1<<24)));
  34. for(i= 0; i<100; i++){
  35. START_TIMER
  36. sf1= av_int2sf(i, 0);
  37. sf2= av_div_sf(av_int2sf(i, 2), av_int2sf(200, 3));
  38. for(j= 0; j<1000; j++){
  39. sf1= av_mul_sf(av_add_sf(sf1, one),sf2);
  40. }
  41. STOP_TIMER("softfloat add mul")
  42. }
  43. printf("test2 sf =%d (%d %d)\n", av_sf2int(sf1, 24), sf1.exp, sf1.mant);
  44. return 0;
  45. }